atm959

SNES Code

Oct 30th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. ;== Include memorymap, header info, and SNES initialization routines
  2. .INCLUDE "header.inc"
  3. .INCLUDE "InitSNES.asm"
  4. .include "LoadGraphics.asm"
  5.  
  6. ;========================
  7. ; Start
  8. ;========================
  9.  
  10. .BANK 0
  11. .ORG 0
  12. .SECTION "MainCode"
  13.  
  14. VBlank:
  15. RTI ; Perform VBlank
  16.  
  17. Main:
  18. InitializeSNES ; Initialize the SNES hardware
  19.  
  20. jsr SetupVideo
  21. LoadPalette BGPalette, 0, 4
  22. LoadBlockToVRAM TileData, $0000, $0432
  23.  
  24. lda #$FF
  25. sta $0800 ;Time ones place.
  26. lda #$00
  27. sta $0801 ;Time tens place.
  28.  
  29. lda #$80
  30. sta $2115
  31.  
  32. ldx #$04B0 ;T
  33. stx $2116
  34. lda #20
  35. sta $2118
  36.  
  37. ldx #$04B1 ;I
  38. stx $2116
  39. lda #09
  40. sta $2118
  41.  
  42. ldx #$04B2 ;M
  43. stx $2116
  44. lda #13
  45. sta $2118
  46.  
  47. ldx #$04B3 ;E
  48. stx $2116
  49. lda #05
  50. sta $2118
  51.  
  52. stz $2121
  53. stz $2122
  54. stz $2122
  55. lda #$01
  56. sta $2121
  57. lda #%11111111
  58. sta $2112
  59. lda #%01111111
  60. sta $2122
  61.  
  62. ldx #$0400
  63. stx $2116
  64. lda #$00
  65. sta $2118
  66.  
  67. PlaceTiles:
  68. inx
  69. stx $2116
  70. ina
  71. cmp #54
  72. beq Loop
  73. sta $2118
  74. jsr wait
  75. jmp PlaceTiles
  76.  
  77. wait:
  78. .REPT $0A
  79. wai
  80. .ENDR
  81. rts
  82.  
  83. Loop:
  84. lda $0800
  85. ina
  86. cmp #10
  87. beq IncrementTens
  88. sta $0800
  89. ldx #$04B5
  90. stx $2116
  91. lda $0801
  92. clc
  93. adc #27
  94. sta $2118
  95. ldx #$04B6
  96. stx $2116
  97. lda $0800
  98. clc
  99. adc #27
  100. sta $2118
  101. jsr wait
  102. jmp Loop
  103.  
  104. IncrementTens:
  105. lda #$FF
  106. sta $0800
  107. lda $0801
  108. ina
  109. sta $0801
  110. jmp Loop
  111.  
  112. ;============================================================================
  113. ; SetupVideo -- Sets up the video mode and tile-related registers
  114. ;----------------------------------------------------------------------------
  115. ; In: None
  116. ;----------------------------------------------------------------------------
  117. ; Out: None
  118. ;----------------------------------------------------------------------------
  119. SetupVideo:
  120. php
  121.  
  122. lda #$00
  123. sta $2105 ; Set Video mode 0, 8x8 tiles, 4 color BG1/BG2/BG3/BG4
  124.  
  125. lda #$04 ; Set BG1's Tile Map offset to $0400 (Word address)
  126. sta $2107 ; And the Tile Map size to 32x32
  127.  
  128. stz $210B ; Set BG1's Character VRAM offset to $0000 (word address)
  129.  
  130. lda #$01 ; Enable BG1
  131. sta $212C
  132.  
  133. lda #$FF
  134. sta $210E
  135. sta $210E
  136.  
  137. lda #$0F
  138. sta $2100 ; Turn on screen, full Brightness
  139.  
  140. plp
  141. rts
  142. ;============================================================================
  143.  
  144. .ENDS
  145.  
  146. .BANK 1
  147. .ORG 0
  148. .SECTION "TileData"
  149. .INCLUDE "tiles.inc"
  150. .ENDS
Add Comment
Please, Sign In to add comment