Advertisement
Guest User

MMC1

a guest
Jul 2nd, 2014
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   .inesprg $10   ; 16x 16KB PRG code
  2.   .ineschr $10   ; 16x  8KB CHR data
  3.   .inesmap $01   ; mapper 1 = MMC1, 4KB CHR bank swapping
  4.   .inesmir 0   ; background mirroring
  5.  
  6.  
  7. ;;;;;;;;;;;; N.B.: This could also probably be done with CNROM. However, this is made to test the MMC1.
  8. ;;;;;;;;;;;; If you want to do a CNROM game for whatever reason, feel free to try and port this to CNROM,
  9. ;;;;;;;;;;;; if you need to refresh your CNROM skillz :P
  10.  
  11.   .rsset $0000
  12.  
  13. bankNumber      .rs 1       ;Bank number :)
  14. title_black     .rs 1       ;A racist variable
  15.  
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.    
  18.   .bank 0
  19.   .org $8000
  20.  
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23.  
  24.   .bank 1
  25.   .org $A000
  26.  
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29.  
  30.   .bank 2
  31.   .org $8000
  32.  
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  35.  
  36.   .bank 3
  37.   .org $A000
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    *Buzz to Woody* Unused banks! Unused banks everywhere!
  41.  
  42.   .bank 4
  43.   .org $8000
  44.  
  45. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  47.  
  48.   .bank 5
  49.   .org $A000
  50.  
  51.  
  52. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54.  
  55.   .bank 6
  56.   .org $8000
  57.  
  58. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  59. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  60.  
  61.   .bank 7
  62.   .org $A000
  63.  
  64.  
  65. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  66. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  67.  
  68.   .bank 8
  69.   .org $8000
  70.  
  71. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  72. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  73.  
  74.   .bank 9
  75.   .org $A000
  76.  
  77. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  78. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  79.  
  80.   .bank 10
  81.   .org $8000
  82.  
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  85.  
  86.   .bank 11
  87.   .org $A000
  88.  
  89.  
  90. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  91. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  92.  
  93.   .bank 12
  94.   .org $8000
  95.  
  96. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  97. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  98.  
  99.   .bank 13
  100.   .org $A000
  101.  
  102.  
  103. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  104. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105.  
  106.   .bank 14
  107.   .org $8000
  108.  
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  111.  
  112.   .bank 15
  113.   .org $A000
  114.  
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  116. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  117.  
  118.   .bank 16
  119.   .org $8000
  120.  
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  123.  
  124.   .bank 17
  125.   .org $A000
  126.  
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  129.  
  130.   .bank 18
  131.   .org $8000
  132.  
  133. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  134. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  135.  
  136.   .bank 19
  137.   .org $A000
  138.  
  139.  
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  142.  
  143.   .bank 20
  144.   .org $8000
  145.  
  146. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  147. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  148.  
  149.   .bank 21
  150.   .org $A000
  151.  
  152.  
  153. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  154. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  155.  
  156.   .bank 22
  157.   .org $8000
  158.  
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  161.  
  162.   .bank 23
  163.   .org $A000
  164.  
  165. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  166. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  167.  
  168.   .bank 24
  169.   .org $8000
  170.  
  171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  172. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  173.  
  174.   .bank 25
  175.   .org $A000
  176.  
  177.  
  178. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  179. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  180.  
  181.   .bank 26
  182.   .org $8000
  183.  
  184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  186.  
  187.   .bank 27
  188.   .org $A000
  189.  
  190.  
  191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  192. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  193.  
  194.   .bank 28
  195.   .org $8000
  196.  
  197. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  198. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  199.  
  200.   .bank 29
  201.   .org $A000
  202.  
  203. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  204. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  205.  
  206.   .bank 30
  207.   .org $C000
  208.  
  209. ;;;;;;;;;;
  210.  
  211. RESET:
  212.   SEI          ; disable IRQs
  213.   CLD          ; disable decimal mode
  214.   LDX #$40
  215.   STX $4017    ; disable APU frame IRQ
  216.   LDX #$FF
  217.   TXS          ; Set up stack
  218.   INX          ; now X = 0
  219.   STX $2000    ; disable NMI
  220.   STX $2001    ; disable rendering
  221.   STX $4010    ; disable DMC IRQs
  222.  
  223. vblankwait1:       ; First wait for vblank to make sure PPU is ready
  224.   BIT $2002
  225.   BPL vblankwait1
  226.  
  227. clrmem:
  228.   LDA #$00
  229.   STA $0000, x
  230.   STA $0100, x
  231.   STA $0300, x
  232.   STA $0400, x
  233.   STA $0500, x
  234.   STA $0600, x
  235.   STA $0700, x
  236.   LDA #$FE
  237.   STA $0200, x
  238.   INX
  239.   BNE clrmem
  240.  
  241.   LDA #$80      ;Reset the MMC1
  242.   STA $8000
  243.  
  244.   LDA #%00011111    ;Horizontal mirroring, 2 4KB CHR banks, 2 16 KB banks, swapping at $8000.
  245.   STA $8000
  246.   LSR A
  247.   STA $8000
  248.   LSR A
  249.   STA $8000
  250.   LSR A
  251.   STA $8000
  252.   LSR A
  253.   STA $8000
  254.  
  255.   LDA #%00000000    ;Set the first bank of CHR to be $0000-$0FFF
  256.   STA $A000
  257.   LSR A
  258.   STA $A000
  259.   LSR A
  260.   STA $A000
  261.   LSR A
  262.   STA $A000
  263.   LSR A
  264.   STA $A000
  265.  
  266.   LDA #%00000001    ;And the second one for the $1000-$1FFF range
  267.   STA $C000
  268.   LSR A
  269.   STA $C000
  270.   LSR A
  271.   STA $C000
  272.   LSR A
  273.   STA $C000
  274.   LSR A
  275.   STA $C000
  276.  
  277.   LDA #%00010000    ;This just sets the PRG bank. For now, no PRG swapping, and no WRAM
  278.   STA $E000
  279.   LSR A
  280.   STA $E000
  281.   LSR A
  282.   STA $E000
  283.   LSR A
  284.   STA $E000
  285.   LSR A
  286.   STA $E000
  287.  
  288. vblankwait2:       ; Second wait for vblank to make sure PPU is ready
  289.   BIT $2002
  290.   BPL vblankwait2
  291.  
  292.  
  293. PalLoad:
  294.   LDA $2002 ;PPU? r u there? We need to reset the HiLo latch!
  295.   LDA #$3F  ;Hi part of $3F00
  296.   STA $2006
  297.   LDA #$00  ;Lo part of it
  298.   STA $2006
  299.   LDX #$00
  300. PalLoop:
  301.   LDA pal, x
  302.   STA $2007 ;Load 'em palettes to PPU
  303.   INX
  304.   CPX #$20
  305.   BNE PalLoop   ;Advance only when all 32 palettes are copied!
  306.   RTS
  307.  
  308.  
  309. LoadTitle:
  310.   LDA $2002
  311.   LDA #$20
  312.   STA $2006
  313.   LDA #$45
  314.   STA $2006 ;Begins at $2000
  315.  
  316.   LDA #$0A  ;Should write tile 0A to the background... DOES JACK SHITHFASIFGSAFIJAHF;AJKSD!!!!1!!111one!!
  317.   STA $2007
  318.  
  319.   LDA #%10010000   ; enable NMI, 8x8 sprites from Pattern Table 0, background from Pattern Table 1
  320.   STA $2000
  321.   LDA #%00011110   ; Enable sprites, enable background, no clipping on left side
  322.   STA $2001
  323.  
  324. Forever:
  325.   JMP Forever
  326.  
  327. NMI:
  328.   LDA #$00
  329.   STA $2003  ; set the low byte (00) of the RAM address
  330.   LDA #$02
  331.   STA $4014  ; set the high byte (02) of the RAM address, start the transfer
  332.  
  333. PPUCleanup:
  334.   LDA #%10010000   ; enable NMI, 8x16 sprites from Pattern Table 0, background from Pattern Table 1
  335.   STA $2000
  336.   LDA #%00011110   ; Enable sprites, enable background, no clipping on left side
  337.   STA $2001
  338.   LDA #$00         ; no scrolling
  339.   STA $2005
  340.   STA $2005
  341.  
  342.   RTI
  343.  
  344.  
  345. ;;;;;;;;;;;;;;;;;;;;;;
  346.  
  347.   .bank 31
  348.   .org $E000
  349.  
  350. pal:
  351.   .db $0F,$1C,$2C,$3C,$1A,$04,$14,$24,$10,$00,$10,$20,$1A,$18,$28,$38
  352.   .db $0F,$0F,$17,$36,$0F,$0F,$21,$36,$0F,$0F,$27,$17,$0F,$07,$2A,$2B
  353.  
  354. title:
  355.   .db $FE,$60
  356.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  357.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  358.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  359.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  360.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  361.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  362.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  363.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  364.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  365.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  366.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  367.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  368.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  369.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  370.   .db $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f
  371.   .db $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f
  372.  
  373.  
  374.   .org $FFFA     ;first of the three vectors starts here
  375.   .dw NMI        ;when an NMI happens (once per frame if enabled) the
  376.                    ;processor will jump to the label NMI:
  377.   .dw RESET      ;when the processor first turns on or is reset, it will jump
  378.                    ;to the label RESET:
  379.   .dw 0          ;external interrupt IRQ is not used in this tutorial
  380.  
  381.  
  382. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  383. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  384.  
  385.   .bank 32
  386.   .org $0000
  387.   .incbin "FoE-spr1.chr"    ;Include the first sprite sheet
  388.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  389.  
  390. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  391. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  392.  
  393.   .bank 33
  394.   .org $0000
  395.   .incbin "FoE-spr2.chr"    ;Include the first sprite sheet
  396.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  397.  
  398. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  399. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  400.  
  401.   .bank 34
  402.   .org $0000
  403.   .incbin "FoE-spr3.chr"    ;Include the first sprite sheet
  404.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  405.  
  406. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  407. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  408.  
  409.   .bank 35
  410.   .org $0000
  411.   .incbin "FoE-spr1.chr"    ;Include the third sprite sheet
  412.  
  413. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  414. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  415.  
  416.   .bank 36
  417.   .org $0000
  418.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  419.  
  420. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  421. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  422.  
  423.   .bank 37
  424.   .org $0000
  425.   .incbin "FoE-spr1.chr"    ;Include the first sprite sheet
  426.  
  427. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  428. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  429.  
  430.   .bank 38
  431.   .org $0000
  432.   .incbin "FoE-spr2.chr"    ;Include the second sprite sheet
  433.  
  434. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  435. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  436.  
  437.   .bank 39
  438.   .org $0000
  439.   .incbin "FoE-spr1.chr"    ;Include the third sprite sheet
  440.  
  441. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  442. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  443.  
  444.   .bank 40
  445.   .org $0000
  446.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  447.  
  448. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  449. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  450.  
  451.   .bank 41
  452.   .org $0000
  453.   .incbin "FoE-spr1.chr"    ;Include the first sprite sheet
  454.  
  455. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  456. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  457.  
  458.   .bank 42
  459.   .org $0000
  460.   .incbin "FoE-spr2.chr"    ;Include the second sprite sheet
  461.  
  462. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  463. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  464.  
  465.   .bank 43
  466.   .org $0000
  467.   .incbin "FoE-spr1.chr"    ;Include the third sprite sheet
  468.  
  469. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  470. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  471.  
  472.   .bank 44
  473.   .org $0000
  474.   .incbin "FoE-bgr.chr"     ;Include the "Faces of Evil" background file
  475.  
  476. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  477. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  478.  
  479.   .bank 45
  480.   .org $0000
  481.   .incbin "FoE-spr1.chr"    ;Include the first sprite sheet
  482.  
  483. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  484. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  485.  
  486.   .bank 46
  487.   .org $0000
  488.   .incbin "FoE-spr2.chr"    ;Include the second sprite sheet
  489.  
  490. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  491. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  492.  
  493.   .bank 47
  494.   .org $0000
  495.   .incbin "FoE-spr1.chr"    ;Include the third sprite sheet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement