Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.87 KB | None | 0 0
  1. ;----------------------------------------------------------------
  2. ; constants
  3. ;----------------------------------------------------------------
  4.  
  5. PRG_COUNT = 1 ;1 = 16KB, 2 = 32KB
  6. MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
  7.  
  8. ;----------------------------------------------------------------
  9. ; variables
  10. ;----------------------------------------------------------------
  11.  
  12. .enum $0000
  13. 00000
  14. 00000 ;NOTE: declare variables using the DSB and DSW directives, like this:
  15. 00000
  16. 00000 ;MyVariable0 .dsb 1
  17. 00000 ;MyVariable1 .dsb 3
  18. 00000
  19. 00000 .ende
  20.  
  21. ;NOTE: you can also split the variable declarations into individual pages, like this:
  22.  
  23. ;.enum $0100
  24. ;.ende
  25.  
  26. ;.enum $0200
  27. ;.ende
  28.  
  29. ;----------------------------------------------------------------
  30. ; iNES header
  31. ;----------------------------------------------------------------
  32.  
  33. 4E 45 53 1A .db "NES", $1a ;identification of the iNES header
  34. 01 .db PRG_COUNT ;number of 16KB PRG-ROM pages
  35. 01 .db $01 ;number of 8KB CHR-ROM pages
  36. 01 .db $00|MIRRORING ;mapper 0 and mirroring
  37. 00 00 00 00 00 00 00 00.. .dsb 9, $00 ;clear the remaining bytes
  38.  
  39. ;----------------------------------------------------------------
  40. ; program bank(s)
  41. ;----------------------------------------------------------------
  42.  
  43. .base $10000-(PRG_COUNT*$4000)
  44. 0C000
  45. 0C000 Reset:
  46. 0C000
  47. 0C000 78 sei ; ignore IRQs
  48. 0C001 D8 cld ; disable decimal mode
  49. 0C002 A2 40 ldx #$40
  50. 0C004 8E 17 40 stx $4017 ; disable APU frame IRQ
  51. 0C007 A2 FF ldx #$ff
  52. 0C009 9A txs ; Set up stack
  53. 0C00A E8 inx ; now X = 0
  54. 0C00B 8E 00 20 stx $2000 ; disable NMI
  55. 0C00E 8E 01 20 stx $2001 ; disable rendering
  56. 0C011 8E 10 40 stx $4010 ; disable DMC IRQs
  57. 0C014
  58. 0C014 ; Optional (omitted):
  59. 0C014 ; Set up mapper and jmp to further init code here.
  60. 0C014
  61. 0C014 ; Clear the vblank flag, so we know that we are waiting for the
  62. 0C014 ; start of a vertical blank and not powering on with the
  63. 0C014 ; vblank flag spuriously set
  64. 0C014 2C 02 20 bit $2002
  65. 0C017
  66. 0C017 ; First of two waits for vertical blank to make sure that the
  67. 0C017 ; PPU has stabilized
  68. 0C017 @vblankwait1:
  69. 0C017 2C 02 20 bit $2002
  70. 0C01A 10 FB bpl @vblankwait1
  71. 0C01C
  72. 0C01C ; We now have about 30,000 cycles to burn before the PPU stabilizes.
  73. 0C01C ; One thing we can do with this time is put RAM in a known state.
  74. 0C01C ; Here we fill it with $00, which matches what (say) a C compiler
  75. 0C01C ; expects for BSS. Conveniently, X is still 0.
  76. 0C01C 8A txa
  77. 0C01D @clrmem:
  78. 0C01D 95 00 sta $000,x
  79. 0C01F 9D 00 01 sta $100,x
  80. 0C022 9D 00 03 sta $300,x
  81. 0C025 9D 00 04 sta $400,x
  82. 0C028 9D 00 05 sta $500,x
  83. 0C02B 9D 00 06 sta $600,x
  84. 0C02E 9D 00 07 sta $700,x ; Remove this if you're storing reset-persistent data
  85. 0C031
  86. 0C031 ; We skipped $200,x on purpose. Usually, RAM page 2 is used for the
  87. 0C031 ; display list to be copied to OAM. OAM needs to be initialized to
  88. 0C031 ; $EF-$FF, not 0, or you'll get a bunch of garbage sprites at (0, 0).
  89. 0C031
  90. 0C031 E8 inx
  91. 0C032 D0 E9 bne @clrmem
  92. 0C034
  93. 0C034 ; Other things you can do between vblank waits are set up audio
  94. 0C034 ; or set up other mapper registers.
  95. 0C034
  96. 0C034 @vblankwait2:
  97. 0C034 2C 02 20 bit $2002
  98. 0C037 10 FB bpl @vblankwait2
  99. 0C039
  100. 0C039
  101. 0C039 A9 3F LDA #$3F
  102. 0C03B 8D 06 20 STA $2006
  103. 0C03E A9 00 LDA #$00
  104. 0C040 8D 06 20 STA $2006
  105. 0C043 A9 2A LDA #$2A
  106. 0C045 8D 07 20 STA $2007
  107. 0C048
  108. 0C048 A9 32 LDA #$32 ;code for light blueish
  109. 0C04A 8D 07 20 STA $2007 ;write to PPU $3F10
  110. 0C04D A9 14 LDA #$14 ;code for pinkish
  111. 0C04F 8D 07 20 STA $2007 ;write to PPU $3F11
  112. 0C052 A9 2A LDA #$2A ;code for greenish
  113. 0C054 8D 07 20 STA $2007 ;write to PPU $3F12
  114. 0C057 A9 16 LDA #$16 ;code for redish
  115. 0C059 8D 07 20 STA $2007 ;write to PPU $3F13
  116. 0C05C A9 32 LDA #$32 ;code for light blueish
  117. 0C05E 8D 07 20 STA $2007 ;write to PPU $3F10
  118. 0C061 A9 32 LDA #$32 ;code for pinkish
  119. 0C063 8D 07 20 STA $2007 ;write to PPU $3F11
  120. 0C066 A9 30 LDA #$30 ;code for greenish
  121. 0C068 8D 07 20 STA $2007 ;write to PPU $3F12
  122. 0C06B A9 30 LDA #$30 ;code for redish
  123. 0C06D 8D 07 20 STA $2007 ;write to PPU $3F13
  124. 0C070
  125. 0C070 A2 00 LDX #$00 ; start out at 0
  126. 0C072 LoadPalettesLoop:
  127. 0C072 BD 00 00 LDA PaletteData, x ; load data from address (PaletteData + the value in x)
  128. *** Unknown label.
  129. 0C075 ; 1st time through loop it will load PaletteData+0
  130. 0C075 ; 2nd time through loop it will load PaletteData+1
  131. 0C075 ; 3rd time through loop it will load PaletteData+2
  132. 0C075 ; etc
  133. 0C075 8D 07 20 STA $2007 ; write to PPU
  134. 0C078 E8 INX ; X = X + 1
  135. 0C079 E0 20 CPX #$20 ; Compare X to hex $20, decimal 32
  136. 0C07B D0 F5 BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  137. 0C07D ; if compare was equal to 32, keep going down
  138. 0C07D
  139. 0C07D
  140. 0C07D A9 18 LDA #%00011000
  141. 0C07F 8D 01 20 STA $2001
  142. 0C082
  143. 0C082
  144. 0C082 loop:
  145. 0C082 4C 82 C0 jmp loop
  146. 0C085
  147. 0C085 NMI:
  148. 0C085
  149. 0C085
  150. 0C085
  151. 0C085 IRQ:
  152. 0C085
  153. 0C085 ;NOTE: IRQ code goes here
  154. 0C085
  155. 0C085 ;----------------------------------------------------------------
  156. 0C085 ; interrupt vectors
  157. 0C085 ;----------------------------------------------------------------
  158. 0C085
  159. 0C085 00 00 00 00 00 00 00 00.. .org $fffa
  160. 0FFFA
  161. 0FFFA 85 C0 .dw NMI
  162. 0FFFC 00 C0 .dw Reset
  163. 0FFFE 85 C0 .dw IRQ
  164. 10000
  165. 10000 ;----------------------------------------------------------------
  166. 10000 ; CHR-ROM bank
  167. 10000 ;----------------------------------------------------------------
  168. 10000
  169. 10000 00 00 00 00 00 00 00 00.. .incbin "pong.chr"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement