SHARE
TWEET

SMW Magic Project MSU1 (v2) MAP16 source

LuigiBlood Jun 13th, 2015 (edited) 235 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lorom
  2.  
  3.  ;Map16 Copy
  4.  ORG $0FF9D0 ;14336 bytes = $3800 bytes
  5.  ;Map16 Low Byte Table = $7E:C800
  6.  ;Map16 High Byte Table = $7F:C800
  7.  !RAMHigh = $7FC00B ;$7F9C7B
  8.  !RAMLow = $7FC00C ;$7F9C7C
  9.  
  10.  LoadMap16LowTable:
  11.         PHP
  12.         PHA
  13.         PHX
  14.         PHY
  15.         REP #$10 ; 16 bit X Y
  16.         SEP #$20 ; 8 bit A
  17.         STZ $2000 ;Set S-MSU1 Address for Data Port
  18.         STZ $2001
  19.         STZ $2002
  20.         STZ $2003
  21.        
  22.   -     LDA $2000 ;Don't start the port to RAM until it's ready
  23.         AND #$80
  24.         CMP #$80
  25.         BNE -
  26.        
  27.         STZ !RAMLow ;RAM : Low Byte, Bytes Recieved.
  28.         STZ !RAMHigh ;RAM : High Byte, Bytes Recieved.
  29.         LDX #$00
  30.         TXS
  31.        
  32. LoadLowLoop:
  33.   -     LDA $2001 ;Byte Port from S-MSU1
  34.         STA [$7EC800],X ;To Map16 Low Byte Table
  35.         LDA !RAMLow ;Check if $FF bytes has been received.
  36.         CMP #$FF
  37.         BEQ HighByteUp ;If yes, go to "HighByteUp"
  38.         INC !RAMLow ;If no, add 1 to received bytes (low)
  39.         INX ;Add 1 to X
  40.         BRA - ;Loop
  41.        
  42. HighByteUp:
  43.         INC !RAMLow
  44.         INC !RAMHigh
  45.         INX
  46.         LDA !RAMHigh
  47.         CPX #$3800
  48.         BEQ LoadMap16HighTable
  49.         JMP LoadLowLoop
  50.        
  51. LoadMap16HighTable:
  52.         STZ $2000
  53.         LDA #$38
  54.         STA $2001
  55.         STZ $2002
  56.         STZ $2003
  57.        
  58.   -     LDA $2000
  59.         AND #$80
  60.         CMP #$80
  61.         BNE -
  62.        
  63.         STZ !RAMLow ;RAM : Low Byte, Bytes Recieved.
  64.         STZ !RAMHigh ;RAM : High Byte, Bytes Recieved.
  65.         LDX #$00
  66.        
  67.        
  68. LoadHighLoop:
  69.   -     LDA $2001
  70.         STA [$7FC800],X
  71.         LDA !RAMLow
  72.         CMP #$FF
  73.         BEQ HighByteUpHigh
  74.         INC !RAMLow
  75.         INX
  76.         BRA -
  77.        
  78. HighByteUpHigh:
  79.         INC !RAMLow
  80.         INC !RAMHigh
  81.         INX
  82.         LDA !RAMHigh
  83.         CMP #$38
  84.         BEQ Stop
  85.         JMP LoadHighLoop
  86.        
  87. Stop:
  88.         PLP ;Gets everything back to normal
  89.         PLA
  90.         PLX
  91.         PLY
  92.        
  93. Stop2:
  94.         LDA.b #$10  ;Insert replaced opcodes here
  95.         STA.w $1DF5
  96.         RTL
  97.        
  98.  
  99. ORG $009AC0 ;Insert JSL somewhere after the Level Loading Routine.
  100.         JSL $0FF9D0
  101.         NOP
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