daily pastebin goal
50%
SHARE
TWEET

move in M68000 is almost turing complete!

Green_Snake Oct 5th, 2015 (edited) 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         opt l+                          ; use . for local lables
  2.         opt d+                          ; descope local lables equ, set, etc.
  3.         opt ae+                         ; automatic even on dc, dcb, ds, rw .w/l
  4.         opt op+                         ; pc relative optimizations
  5.  
  6. ; ===========================================================================
  7. VDP_Data_Port           equ $C00000
  8. VDP_Control_Port        equ $C00004
  9. VDP_Counter             equ $C00008
  10.  
  11. ; ===========================================================================
  12. _rts            macro
  13.         move.w  d0,1.w          ; cause address error
  14.         endm
  15.        
  16. _end            macro
  17.                 move.l  a0,usp          ; cause privilege violation error
  18.         endm
  19.  
  20. asc             macro
  21.         rept narg
  22.                 dc.w \1
  23.         shift
  24.         endr
  25.         endm
  26.  
  27. ; ===========================================================================
  28. dma macro       source,dest,length,type
  29.         move.l  #(($9400|((((length)>>1)&$FF00)>>8))<<16)|($9300|(((length)>>1)&$FF)),(a1)
  30.         move.l  #(($9600|((((source)>>1)&$FF00)>>8))<<16)|($9500|(((source)>>1)&$FF)),(a1)
  31.         move.l  #(($9700|(((((source)>>1)&$FF0000)>>16)&$7F))<<16)|((((dest)&$3FFF)|((type&1)<<15)|$4000)),(a1)
  32.         move.w  #$80|(((dest)&$C000)>>14)|((type&2)<<3),(a1)
  33.     endm
  34.  
  35. ; values for the type argument
  36. VRAM =  $0
  37. CRAM =  $1
  38. VSRAM = $2
  39.  
  40. ; ===========================================================================
  41.                 dc.l $FF0000, EntryPoint, ErrorTrap, $FF0000
  42.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  43.                 dc.l Code_End, ErrorTrap, ErrorTrap, ErrorTrap
  44.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  45.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  46.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  47.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  48.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  49.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  50.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  51.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  52.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  53.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  54.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  55.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  56.                 dc.l ErrorTrap, ErrorTrap, ErrorTrap, ErrorTrap
  57. Console:        dc.b 'SEGA' ; Hardware system ID
  58. ; ===========================================================================
  59. StartofRAM
  60.  
  61. LoadFont:
  62.                 move.l  #VDP_Data_Port,a0
  63.                 move.l  #VDP_Control_Port,a1
  64.  
  65.                 move.w  #VDPregs,a2
  66.                 rept    24/2
  67.                 move.l  (a2)+,(a1)              ; move VDP register data
  68.                 endr
  69.  
  70.                 move.l  #$C00A0000,(a1)         ; CRAM write $A
  71.                 move.l  #$EEE,(a0)              ; write the palette
  72.  
  73.                 dma     EndOfROM,  $C000, $400,   VRAM  ; DMA Plane A and B mappings
  74.                 dma     EndOfROM,  $C400, $400,   VRAM  ; DMA Plane A and B mappings
  75.                 dma     EndOfROM,  $0000, 32,     VRAM  ; DMA blank tile
  76.                 dma     Font_GFX,  $0600, $2A*32, VRAM  ; DMA art
  77.  
  78.                 move.l  #$42100003,(a1)
  79.                 move.w  #Data_Maps,a2
  80.  
  81.                 rept    16/2
  82.                 move.l  (a2)+,(a0)                      ; write the mappings
  83.                 endr
  84.  
  85. code_asc        move.l  #0,(a0)                         ; write EU/US/JP depending on region
  86.  
  87.                 moveq   #0,d0
  88.                 move.l  d0,a0
  89.                 move.l  a0,usp                          ; prepare Privilege Violation
  90.  
  91. ErrorTrap:
  92. Code_End:       _end                                    ; cause privilege violation
  93. EndofRAM
  94.  
  95.  
  96. ; ===========================================================================
  97. VDPregs:        dc.w $8004, $8154, $8230, $8332
  98.                 dc.w $8406, $8562, $8600, $8705
  99.                 dc.w $8800, $8900, $8A00, $8B00
  100.                 dc.w $8C71, $8D3F, $8E00, $8F02
  101.                 dc.w $9000, $9100, $9200, $93FF
  102.                 dc.w $94FF, $9500, $9600, $9780
  103. ; ===========================================================================
  104. EntryPoint:
  105.                 moveq   #0,d0
  106.                 move.b  $A10001,d0
  107.                 move.w  #Data_truthtable,a0
  108.                 move.b  (a0,d0.w),d0            ; get regional settings
  109.  
  110.                 move.w  #StartofRAM,a0
  111.                 move.l  #$FF0000,a1
  112.  
  113.                 rept    ((EndofRAM-StartofRAM)/4)
  114.                 move.l  (a0)+,(a1)+             ; move ROM area to RAM
  115.                 endr
  116.  
  117.                 move.w  #Data_Values,a0
  118.                 move.l  (a0,d0.w),a0            ; get pointer to regional setting data
  119.  
  120.                 move.l (a0)+,a1                 ; get address ($FFFFFC or A14000)
  121.                 move.l  #'SEGA',(a1)            ; move SEGA
  122.                 move.b (a0)+,$FF0000+(code_asc-StartofRAM)+3
  123.                 move.b (a0),$FF0000+(code_asc-StartofRAM)+5     ; set region ascii
  124.                 _rts
  125.  
  126. ; ===========================================================================
  127. Data_truthtable dc.b 10*1       ; TMSS JP
  128.                 dcb.b $7F, 10*0 ; non-TMSS JP
  129.                 dc.b 10*3       ; TMSS US
  130.                 dcb.b $3F, 10*2 ; non-TMSS US
  131.                 dc.b 10*5       ; TMSS EU
  132.                 dcb.b $3F, 10*4 ; non-TMSS EU
  133.  
  134. ; ===========================================================================
  135. Data_Values:    dc.l *+4, -4
  136.                 dc.w 'JP'       ; non-TMSS JP
  137.  
  138.                 dc.l *+4, $A14000
  139.                 dc.w 'JP'       ; TMSS JP
  140.  
  141.                 dc.l *+4, -4
  142.                 dc.w 'US'       ; non-TMSS US
  143.                
  144.                 dc.l *+4, $A14000
  145.                 dc.w 'US'       ; TMSS US
  146.                
  147.                 dc.l *+4, -4
  148.                 dc.w 'EU'       ; non-TMSS EU
  149.  
  150.                 dc.l *+4, $A14000
  151.                 dc.w 'EU'       ; TMSS EU
  152.  
  153. ; ===========================================================================
  154. Data_Maps:      asc $59,'M','A','C','H','I','N','E',$59,'R','E','G','I','O','N',$59
  155. ; ===========================================================================
  156. Font_GFX:
  157.         dc.l $00000000, $00000000, $00666600, $06600660, $66606660, $66660660, $66006600, $06666000
  158.         dc.l $00000000, $00000000, $00066600, $00606600, $00006600, $00066000, $00066000, $06666600
  159.         dc.l $00000000, $00000000, $00666000, $06006600, $00006600, $00066000, $00660000, $06666600
  160.         dc.l $00000000, $00000000, $06666600, $00006600, $00066000, $00006600, $06006600, $06666000
  161.         dc.l $00000000, $00000000, $00066600, $00606600, $06006000, $66666660, $00066000, $00666000
  162.         dc.l $00000000, $00000000, $00666600, $00600000, $00666600, $00000660, $06006660, $00666600
  163.         dc.l $00000000, $00000000, $00066600, $00660000, $06666000, $66006600, $66006600, $66666000
  164.         dc.l $00000000, $00000000, $06666600, $06006600, $00066000, $00660000, $06600000, $66600000
  165.         dc.l $00000000, $00000000, $00666600, $06600660, $00666600, $06666000, $66006600, $06666000
  166.         dc.l $00000000, $00000000, $00666600, $06600660, $06600660, $00666600, $00006600, $06666000
  167.         dc.l $00000000, $00060000, $00666600, $06060000, $00666000, $00060600, $06666000, $00060000
  168.         dc.l $00000000, $00000000, $00000000, $00000000, $06666660, $00000000, $00000000, $00000000
  169.         dc.l $00000000, $00000000, $00000000, $06666660, $00000000, $06666660, $00000000, $00000000
  170.         dc.l $00000000, $00006000, $00006600, $06666660, $06666660, $00006600, $00006000, $00000000
  171.         dc.l $00000000, $00006000, $00006600, $06666660, $06666660, $00006600, $00006000, $00000000
  172.         dc.l $00000000, $00000000, $06600660, $06600660, $00606600, $00666000, $06660000, $66600000
  173.         dc.l $00000000, $00000000, $06666660, $00006600, $00066000, $00660000, $06600000, $66666600
  174.         dc.l $00000000, $00000000, $00006660, $00060660, $00600660, $00666660, $06600660, $66000660
  175.         dc.l $00000000, $00000000, $00666600, $00600660, $06666600, $06666000, $66006600, $66666000
  176.         dc.l $00000000, $00000000, $00666600, $06600660, $06600000, $66000000, $66006600, $66666000
  177.         dc.l $00000000, $00000000, $00666600, $00660660, $06600660, $06600660, $66006600, $66666000
  178.         dc.l $00000000, $00000000, $00666660, $00660000, $06600000, $06666000, $66000000, $66666600
  179.         dc.l $00000000, $00000000, $00666660, $06660000, $06600000, $06666600, $66600000, $66600000
  180.         dc.l $00000000, $00000000, $00666600, $06660060, $06600000, $66006660, $66006600, $66666600
  181.         dc.l $00000000, $00000000, $00660060, $00660660, $06600660, $06666600, $66006600, $66006600
  182.         dc.l $00000000, $00000000, $00066000, $00066000, $00660000, $00660000, $06600000, $06600000
  183.         dc.l $00000000, $00000000, $00000660, $00000660, $06006600, $66006600, $66666000, $06660000
  184.         dc.l $00000000, $00000000, $00660060, $00660660, $06606600, $06666000, $66006600, $66000660
  185.         dc.l $00000000, $00000000, $00066000, $00660000, $06600000, $06600000, $66000000, $66666600
  186.         dc.l $00000000, $00000000, $00660060, $00660660, $00666660, $06060660, $06000660, $66000660
  187.         dc.l $00000000, $00000000, $00660060, $00660060, $00666060, $06066600, $06006600, $66006600
  188.         dc.l $00000000, $00000000, $00666600, $06600660, $66606660, $66606660, $66006600, $06666000
  189.         dc.l $00000000, $00000000, $00666600, $00660060, $06600660, $06666600, $66600000, $66000000
  190.         dc.l $00000000, $00000000, $00666600, $06600660, $66000660, $66666660, $66006600, $66666660
  191.         dc.l $00000000, $00000000, $00666600, $00660060, $06600660, $06666600, $66006600, $66006660
  192.         dc.l $00000000, $00000000, $00666660, $06600660, $06660000, $00666600, $66006660, $66666600
  193.         dc.l $00000000, $00000000, $06666660, $00066000, $00066000, $00660000, $00660000, $00660000
  194.         dc.l $00000000, $00000000, $00660060, $00660060, $06600660, $06600600, $66666600, $66666000
  195.         dc.l $00000000, $00000000, $06600060, $06600060, $06600660, $06606600, $06666000, $66660000
  196.         dc.l $00000000, $00000000, $66000060, $66000060, $66060660, $66666600, $66006600, $66006600
  197.         dc.l $00000000, $00000000, $06600060, $06660600, $00666000, $00066000, $00666600, $66006660
  198.  
  199. ; ===========================================================================
  200. EndOfROM:       dcb.b $400,0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top