Advertisement
Guest User

Login NES

a guest
Nov 23rd, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .inesprg 1 ; 1x 16KB PRG code
  2.     .ineschr 1 ; 1x 8KB CHR data
  3.     .inesmap 0 ; mapper 0 = NROM, no bank swapping
  4.     .inesmir 1 ; background mirroring
  5.  
  6.  
  7.     ;;;;;;;;;;;;;;;
  8.  
  9.     ;; DECLARE SOME VARIABLES HERE
  10.     .rsset $0000 ;;start variables at ram location 0
  11.  
  12. gamestate .rs 1 ; .rs 1 means reserve one byte of space
  13. ballx .rs 1 ; ball horizontal position
  14. bally .rs 1 ; ball vertical position
  15. ballup .rs 1 ; 1 = ball moving up
  16. balldown .rs 1 ; 1 = ball moving down
  17. ballleft .rs 1 ; 1 = ball moving left
  18. ballright .rs 1 ; 1 = ball moving right
  19. ballspeedx .rs 1 ; ball horizontal speed per frame
  20. ballspeedy .rs 1 ; ball vertical speed per frame
  21. paddle1ytop .rs 1 ; player 1 paddle top vertical position
  22. paddle12 .rs 1
  23. paddle13 .rs 1
  24. paddle14 .rs 1
  25. paddle21 .rs 1 ; player 2 paddle bottom vertical position
  26. paddle22 .rs 1
  27. paddle23 .rs 1
  28. paddle24 .rs 1
  29. buttons1 .rs 1 ; player 1 gamepad buttons, one bit per button
  30. buttons2 .rs 1 ; player 2 gamepad buttons, one bit per button
  31. score1 .rs 1 ; player 1 score, 0-15
  32. score2 .rs 1 ; player 2 score, 0-15
  33.  
  34.  
  35.     ;; DECLARE SOME CONSTANTS HERE
  36. STATETITLE = $00 ; displaying title screen
  37. STATEPLAYING = $01 ; move paddles/ball, check for collisions
  38. STATEGAMEOVER = $02 ; displaying game over screen
  39.  
  40. RIGHTWALL = $F4 ; when ball reaches one of these, do something
  41. TOPWALL = $08
  42. BOTTOMWALL = $E0
  43. LEFTWALL = $04
  44.  
  45. PADDLE1X = $08 ; horizontal position for paddles, doesnt move
  46. PADDLE2X = $F0
  47.  
  48.     ;;;;;;;;;;;;;;;;;;
  49.  
  50.  
  51.  
  52.  
  53.     .bank 0
  54.     .org $C000
  55.     RESET:
  56.     SEI ; disable IRQs
  57.     CLD ; disable decimal mode
  58.     LDX #$40
  59.     STX $4017 ; disable APU frame IRQ
  60.     LDX #$FF
  61.     TXS ; Set up stack
  62.     INX ; now X = 0
  63.     STX $2000 ; disable NMI
  64.     STX $2001 ; disable rendering
  65.     STX $4010 ; disable DMC IRQs
  66.  
  67.     vblankwait1: ; First wait for vblank to make sure PPU is ready
  68.     BIT $2002
  69.     BPL vblankwait1
  70.  
  71.     clrmem:
  72.     LDA #$00
  73.     STA $0000, x
  74.     STA $0100, x
  75.     STA $0300, x
  76.     STA $0400, x
  77.     STA $0500, x
  78.     STA $0600, x
  79.     STA $0700, x
  80.     LDA #$FE
  81.     STA $0200, x
  82.     INX
  83.     BNE clrmem
  84.  
  85.     vblankwait2: ; Second wait for vblank, PPU is ready after this
  86.     BIT $2002
  87.     BPL vblankwait2
  88.  
  89.  
  90.     LoadPalettes:
  91.     LDA $2002 ; read PPU status to reset the high/low latch
  92.     LDA #$3F
  93.     STA $2006 ; write the high byte of $3F00 address
  94.     LDA #$00
  95.     STA $2006 ; write the low byte of $3F00 address
  96.     LDX #$00 ; start out at 0
  97.     LoadPalettesLoop:
  98.     LDA palette, x ; load data from address (palette + the value in x)
  99.     ; 1st time through loop it will load palette+0
  100.     ; 2nd time through loop it will load palette+1
  101.     ; 3rd time through loop it will load palette+2
  102.     ; etc
  103.     STA $2007 ; write to PPU
  104.     INX ; X = X + 1
  105.     CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  106.     BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  107.     ; if compare was equal to 32, keep going down
  108.  
  109.     LDA $2002 ; read PPU status to reset the high/low latch
  110.     LDA #$20
  111.     STA $2006 ; write the high byte of $2000 address
  112.     LDA #$00
  113.     STA $2006 ; write the low byte of $2000 address
  114.     LDX #$00 ; start out at 0
  115.     LoadBackground1:
  116.     LDA background1, x ; load data from address (background + the value in x)
  117.     STA $2007 ; write to PPU
  118.     INX ; X = X + 1
  119.     CPX #$00 ; Compare X to hex $80, decimal 128 - copying 128 bytes
  120.     BNE LoadBackground1 ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  121.     ; if compare was equal to 128, keep going down
  122.  
  123.     LoadBackground2:
  124.     LDA background1, x ; load data from address (background + the value in x)
  125.     STA $2007 ; write to PPU
  126.     INX ; X = X + 1
  127.     CPX #$00 ; Compare X to hex $80, decimal 128 - copying 128 bytes
  128.     BNE LoadBackground2 ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  129.     ; if compare was equal to 128, keep going down
  130.  
  131.     LoadBackground3:
  132.     LDA background1, x ; load data from address (background + the value in x)
  133.     STA $2007 ; write to PPU
  134.     INX ; X = X + 1
  135.     CPX #$00 ; Compare X to hex $80, decimal 128 - copying 128 bytes
  136.     BNE LoadBackground3 ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  137.     ; if compare was equal to 128, keep going down
  138.  
  139.     LoadBackground4:
  140.     LDA background1, x ; load data from address (background + the value in x)
  141.     STA $2007 ; write to PPU
  142.     INX ; X = X + 1
  143.     CPX #$00 ; Compare X to hex $80, decimal 128 - copying 128 bytes
  144.     BNE LoadBackground4 ; Branch to LoadBackgroundLoop if compare was Not Equal to zero
  145.     ; if compare was equal to 128, keep going down
  146.  
  147.     LoadAttribute:
  148.     LDA $2002 ; read PPU status to reset the high/low latch
  149.     LDA #$23
  150.     STA $2006 ; write the high byte of $23C0 address
  151.     LDA #$C0
  152.     STA $2006 ; write the low byte of $23C0 address
  153.     LDX #$00 ; start out at 0
  154.     LoadAttributeLoop:
  155.     LDA attribute, x ; load data from address (attribute + the value in x)
  156.     STA $2007 ; write to PPU
  157.     INX ; X = X + 1
  158.     CPX #$10 ; Compare X to hex $08, decimal 8 - copying 8 bytes
  159.     BNE LoadAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
  160.     ; if compare was equal to 128, keep going down
  161.  
  162.  
  163.  
  164.  
  165.  
  166.     ;;;Set some initial ball stats
  167.     LDA #$01
  168.     STA balldown
  169.     STA ballright
  170.     LDA #$00
  171.     STA ballup
  172.     STA ballleft
  173.  
  174.     LDA #$50
  175.     STA bally
  176.  
  177.     LDA #$80
  178.     STA ballx
  179.  
  180.     LDA #$02
  181.     STA ballspeedx
  182.     STA ballspeedy
  183.  
  184.  
  185.     LDA #$70
  186.     STA paddle1ytop
  187.  
  188.     LDA #$78
  189.     STA paddle12
  190.  
  191.     LDA #$80
  192.     STA paddle13
  193.  
  194.     LDA #$88
  195.     STA paddle14
  196.  
  197.  
  198.     LDA #$70
  199.     STA paddle21
  200.  
  201.     LDA #$78
  202.     STA paddle22
  203.  
  204.     LDA #$80
  205.     STA paddle23
  206.  
  207.     LDA #$88
  208.     STA paddle24
  209.  
  210.  
  211.  
  212.     ;;:Set starting game state
  213.     LDA #STATEPLAYING
  214.     STA gamestate
  215.  
  216.  
  217.  
  218.     LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  219.     STA $2000
  220.  
  221.     LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  222.     STA $2001
  223.  
  224.     Forever:
  225.     JMP Forever ;jump back to Forever, infinite loop, waiting for NMI
  226.  
  227.  
  228.  
  229.     NMI:
  230.     LDA #$00
  231.     STA $2003 ; set the low byte (00) of the RAM address
  232.     LDA #$02
  233.     STA $4014 ; set the high byte (02) of the RAM address, start the transfer
  234.  
  235.     JSR DrawScore
  236.  
  237.  
  238.     ;;This is the PPU clean up section, so rendering the next frame starts properly.
  239.     LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  240.     STA $2000
  241.     LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  242.     STA $2001
  243.     LDA #$00 ;;tell the ppu there is no background scrolling
  244.     STA $2005
  245.     STA $2005
  246.  
  247.     ;;;all graphics updates done by here, run game engine
  248.  
  249.  
  250.     JSR ReadController1 ;;get the current button data for player 1
  251.     JSR ReadController2 ;;get the current button data for player 2
  252.  
  253.  
  254.  
  255.  
  256.  
  257.     GameEngine:
  258.     LDA gamestate
  259.     CMP #STATETITLE
  260.     BEQ EngineTitle ;;game is displaying title screen
  261.  
  262.     LDA gamestate
  263.     CMP #STATEGAMEOVER
  264.     BEQ EngineGameOver ;;game is displaying ending screen
  265.  
  266.     LDA gamestate
  267.     CMP #STATEPLAYING
  268.     BEQ EnginePlaying ;;game is playing
  269.     GameEngineDone:
  270.  
  271.     JSR UpdateSprites ;;set ball/paddle sprites from positions
  272.  
  273.     RTI ; return from interrupt
  274.  
  275.  
  276.  
  277.  
  278.     ;;;;;;;;
  279.  
  280.     EngineTitle:
  281.     ;;if start button pressed
  282.     ;; turn screen off
  283.     ;; load game screen
  284.     ;; set starting paddle/ball position
  285.     ;; go to Playing State
  286.     ;; turn screen on
  287.     JMP GameEngineDone
  288.  
  289.     ;;;;;;;;;
  290.  
  291.     EngineGameOver:
  292.     ;;if start button pressed
  293.     ;; turn screen off
  294.     ;; load title screen
  295.     ;; go to Title State
  296.     ;; turn screen on
  297.     JMP GameEngineDone
  298.  
  299.     ;;;;;;;;;;;
  300.  
  301.     EnginePlaying:
  302.  
  303.     MoveBallRight:
  304.     LDA ballright
  305.     BEQ MoveBallRightDone ;;if ballright=0, skip this section
  306.  
  307.     LDA ballx
  308.     CLC
  309.     ADC ballspeedx ;;ballx position = ballx + ballspeedx
  310.     STA ballx
  311.  
  312.     LDA ballx
  313.     CMP #RIGHTWALL
  314.     BCC MoveBallRightDone ;;if ball x < right wall, still on screen, skip next section
  315.     LDA #$00
  316.     STA ballright
  317.     LDA #$01
  318.     STA ballleft ;;bounce, ball now moving left
  319.     ;;in real game, give point to player 1, reset ball
  320.     MoveBallRightDone:
  321.  
  322.  
  323.     MoveBallLeft:
  324.     LDA ballleft
  325.     BEQ MoveBallLeftDone ;;if ballleft=0, skip this section
  326.  
  327.     LDA ballx
  328.     SEC
  329.     SBC ballspeedx ;;ballx position = ballx - ballspeedx
  330.     STA ballx
  331.  
  332.     LDA ballx
  333.     CMP #LEFTWALL
  334.     BCS MoveBallLeftDone ;;if ball x > left wall, still on screen, skip next section
  335.     LDA #$01
  336.     STA ballright
  337.     LDA #$00
  338.     STA ballleft ;;bounce, ball now moving right
  339.     ;;in real game, give point to player 2, reset ball
  340.     MoveBallLeftDone:
  341.  
  342.  
  343.     MoveBallUp:
  344.     LDA ballup
  345.     BEQ MoveBallUpDone ;;if ballup=0, skip this section
  346.  
  347.     LDA bally
  348.     SEC
  349.     SBC ballspeedy ;;bally position = bally - ballspeedy
  350.     STA bally
  351.  
  352.     LDA bally
  353.     CMP #TOPWALL
  354.     BCS MoveBallUpDone ;;if ball y > top wall, still on screen, skip next section
  355.     LDA #$01
  356.     STA balldown
  357.     LDA #$00
  358.     STA ballup ;;bounce, ball now moving down
  359.     MoveBallUpDone:
  360.  
  361.  
  362.     MoveBallDown:
  363.     LDA balldown
  364.     BEQ MoveBallDownDone ;;if ballup=0, skip this section
  365.  
  366.     LDA bally
  367.     CLC
  368.     ADC ballspeedy ;;bally position = bally + ballspeedy
  369.     STA bally
  370.  
  371.     LDA bally
  372.     CMP #BOTTOMWALL
  373.     BCC MoveBallDownDone ;;if ball y < bottom wall, still on screen, skip next section
  374.     LDA #$00
  375.     STA balldown
  376.     LDA #$01
  377.     STA ballup ;;bounce, ball now moving down
  378.     MoveBallDownDone:
  379.  
  380.  
  381.  
  382.  
  383.     MovePaddle1ytop:
  384.     LDA buttons1
  385.     AND #%00001000
  386.     BEQ MovePaddle1ytopDone
  387.  
  388.     LDA paddle1ytop
  389.     SEC
  390.     SBC #$01
  391.     STA paddle1ytop
  392.     MovePaddle1ytopDone:
  393.  
  394.  
  395.  
  396.     DownPaddle1ytop:
  397.     LDA buttons1
  398.     AND #%00000100
  399.     BEQ DownPaddle1ytopDone
  400.  
  401.     LDA paddle1ytop
  402.     CLC
  403.     ADC #$01
  404.     STA paddle1ytop
  405.     DownPaddle1ytopDone:
  406.  
  407.  
  408.  
  409.  
  410.     MovePaddle12:
  411.     LDA buttons1
  412.     AND #%00001000
  413.     BEQ MovePaddle12Done
  414.  
  415.     LDA paddle12
  416.     SEC
  417.     SBC #$01
  418.     STA paddle12
  419.     MovePaddle12Done:
  420.  
  421.  
  422.  
  423.     DownPaddle12:
  424.     LDA buttons1
  425.     AND #%00000100
  426.     BEQ DownPaddle12Done
  427.  
  428.     LDA paddle12
  429.     CLC
  430.     ADC #$01
  431.     STA paddle12
  432.     DownPaddle12Done:
  433.  
  434.  
  435.     MovePaddle13:
  436.     LDA buttons1
  437.     AND #%00001000
  438.     BEQ MovePaddle13Done
  439.  
  440.     LDA paddle13
  441.     SEC
  442.     SBC #$01
  443.     STA paddle13
  444.     MovePaddle13Done:
  445.  
  446.  
  447.  
  448.     DownPaddle13:
  449.     LDA buttons1
  450.     AND #%00000100
  451.     BEQ DownPaddle13Done
  452.  
  453.     LDA paddle13
  454.     CLC
  455.     ADC #$01
  456.     STA paddle13
  457.     DownPaddle13Done:
  458.  
  459.  
  460.  
  461.     MovePaddle14:
  462.     LDA buttons1
  463.     AND #%00001000
  464.     BEQ MovePaddle14Done
  465.  
  466.     LDA paddle14
  467.     SEC
  468.     SBC #$01
  469.     STA paddle14
  470.     MovePaddle14Done:
  471.  
  472.  
  473.  
  474.     DownPaddle14:
  475.     LDA buttons1
  476.     AND #%00000100
  477.     BEQ DownPaddle14Done
  478.  
  479.     LDA paddle14
  480.     CLC
  481.     ADC #$01
  482.     STA paddle14
  483.     DownPaddle14Done:
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.     MovePaddle21:
  494.     LDA buttons2
  495.     AND #%00001000
  496.     BEQ MovePaddle21Done
  497.  
  498.     LDA paddle21
  499.     SEC
  500.     SBC #$01
  501.     STA paddle21
  502.     MovePaddle21Done:
  503.  
  504.  
  505.  
  506.     DownPaddle21:
  507.     LDA buttons2
  508.     AND #%00000100
  509.     BEQ DownPaddle21Done
  510.  
  511.  
  512.  
  513.     LDA paddle21
  514.     CLC
  515.     ADC #$01
  516.     STA paddle21
  517.     DownPaddle21Done:
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.     LDA ballx
  528.     CMP PADDLE1X
  529.     BCC Skip
  530.  
  531.  
  532.  
  533.     LDA bally
  534.     CMP paddle1ytop
  535.     BCC Skip
  536.  
  537.     LDA bally
  538.     CMP paddle12
  539.     BCS Skip
  540.  
  541.     LDA #$00
  542.     STA ballright
  543.     LDA #$01
  544.     STA ballleft
  545.  
  546.  
  547.     Skip:
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.     JMP GameEngineDone
  562.     RTS
  563.  
  564.  
  565.  
  566.     UpdateSprites:
  567.     LDA bally ;;update all ball sprite info
  568.     STA $0200
  569.  
  570.     LDA #$00
  571.     STA $0201
  572.  
  573.     LDA #$00
  574.     STA $0202
  575.  
  576.     LDA ballx
  577.     STA $0203
  578.  
  579.     LDA paddle1ytop
  580.     STA $0204
  581.  
  582.     LDA #$37
  583.     STA $0205
  584.  
  585.     LDA #$00
  586.     STA $0206
  587.  
  588.     LDA #$08
  589.     STA $0207
  590.  
  591.     LDA paddle12
  592.     STA $0208
  593.  
  594.     LDA #$47
  595.     STA $0209
  596.  
  597.     LDA #$00
  598.     STA $020A
  599.  
  600.     LDA #$08
  601.     STA $020B
  602.  
  603.     LDA paddle13
  604.     STA $020C
  605.  
  606.     LDA #$57
  607.     STA $020D
  608.  
  609.     LDA #$00
  610.     STA $020E
  611.  
  612.     LDA #$08
  613.     STA $020F
  614.  
  615.     LDA paddle14
  616.     STA $0210
  617.  
  618.     LDA #$67
  619.     STA $0211
  620.  
  621.     LDA #$00
  622.     STA $0212
  623.  
  624.     LDA #$08
  625.     STA $0213
  626.  
  627.     LDA paddle21
  628.     STA $0214
  629.  
  630.     LDA #$37
  631.     STA $0215
  632.  
  633.     LDA #$00
  634.     STA $0216
  635.  
  636.     LDA #$0F0
  637.     STA $0217
  638.  
  639.     LDA #$78 ;;update paddle sprites
  640.     STA $0218
  641.  
  642.     LDA #$47
  643.     STA $0219
  644.  
  645.     LDA #$00
  646.     STA $021A
  647.  
  648.     LDA #$F0
  649.     STA $021B
  650.  
  651.     LDA #$80 ;;update paddle sprites3
  652.     STA $021C
  653.  
  654.     LDA #$57
  655.     STA $021D
  656.  
  657.     LDA #$00
  658.     STA $021E
  659.  
  660.     LDA #$F0
  661.     STA $021F
  662.  
  663.     LDA #$88 ;;update paddle sprites
  664.     STA $0220
  665.  
  666.     LDA #$67
  667.     STA $0221
  668.  
  669.     LDA #$00
  670.     STA $0222
  671.  
  672.     LDA #$F0
  673.     STA $0223
  674.  
  675.  
  676.  
  677.     RTS
  678.  
  679.  
  680.     DrawScore:
  681.     ;;draw score on screen using background tiles
  682.     ;;or using many sprites
  683.     RTS
  684.  
  685.  
  686.  
  687.     ReadController1:
  688.     LDA #$01
  689.     STA $4016
  690.     LDA #$00
  691.     STA $4016
  692.     LDX #$08
  693.     ReadController1Loop:
  694.     LDA $4016
  695.     LSR A ; bit0 -> Carry
  696.     ROL buttons1 ; bit0 <- Carry
  697.     DEX
  698.     BNE ReadController1Loop
  699.     RTS
  700.  
  701.     ReadController2:
  702.     LDA #$01
  703.     STA $4016
  704.     LDA #$00
  705.     STA $4016
  706.     LDX #$08
  707.     ReadController2Loop:
  708.     LDA $4017
  709.     LSR A ; bit0 -> Carry
  710.     ROL buttons2 ; bit0 <- Carry
  711.     DEX
  712.     BNE ReadController2Loop
  713.     RTS
  714.  
  715.  
  716.  
  717.  
  718.     ;;;;;;;;;;;;;;
  719.  
  720.  
  721.  
  722.     .bank 1
  723.     .org $E000
  724.     palette:
  725.     .db $22,$29,$1A,$0F, $22,$36,$17,$0F, $22,$30,$21,$0F, $22,$27,$17,$0F ;;background palette
  726.     .db $22,$1C,$15,$14, $22,$02,$38,$3C, $22,$1C,$15,$14, $22,$02,$38,$3C ;;sprite palette
  727.  
  728.     sprites:
  729.     ;vert tile attr horiz
  730.     .db $80, $00, $00, $80 ;sprite 0
  731.  
  732.     .db $70, $37, $00, $08 ;sprite 1
  733.     .db $78, $47, $00, $08 ;sprite 2
  734.     .db $80, $57, $00, $08 ;sprite 3
  735.     .db $88, $67, $00, $08 ;sprite 4
  736.  
  737.     .db $70, $37, $00, $F0 ;sprite 1
  738.     .db $78, $47, $00, $F0 ;sprite 2
  739.     .db $80, $57, $00, $F0 ;sprite 3
  740.     .db $88, $67, $00, $F0 ;sprite 4
  741.  
  742.  
  743.  
  744.     background1:
  745.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  746.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  747.  
  748.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  749.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  750.  
  751.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  752.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  753.  
  754.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  755.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  756.  
  757.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  758.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  759.  
  760.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  761.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  762.  
  763.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  764.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  765.  
  766.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  767.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  768.  
  769.     background2:
  770.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  771.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  772.  
  773.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  774.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  775.  
  776.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  777.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  778.  
  779.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  780.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  781.  
  782.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  783.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  784.  
  785.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  786.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  787.  
  788.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  789.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  790.  
  791.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  792.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  793.  
  794.     background3:
  795.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  796.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  797.  
  798.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  799.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  800.  
  801.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  802.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  803.  
  804.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  805.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  806.  
  807.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  808.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  809.  
  810.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  811.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  812.  
  813.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  814.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  815.  
  816.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  817.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  818.  
  819.     background4:
  820.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  821.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  822.  
  823.     .db $1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D
  824.     .db $1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D,$1D
  825.  
  826.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  827.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  828.  
  829.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  830.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  831.  
  832.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  833.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  834.  
  835.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  836.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  837.  
  838.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  839.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  840.  
  841.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  842.     .db $24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24,$24
  843.  
  844.     attribute:
  845.     .db %00000000, %00010000, %01010000, %00010000, %00000000, %00000000, %00000000, %00110000
  846.     .db %00000000, %00010000, %01010000, %00010000, %00000000, %00000000, %00000000, %00110000
  847.  
  848.     .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  849.     .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  850.  
  851.     .db %00000000, %00010000, %01010000, %00010000, %00000000, %00000000, %00000000, %00110000
  852.     .db %00000000, %00010000, %01010000, %00010000, %00000000, %00000000, %00000000, %00110000
  853.  
  854.     .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  855.     .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  856.  
  857.  
  858.  
  859.     .org $FFFA ;first of the three vectors starts here
  860.     .dw NMI ;when an NMI happens (once per frame if enabled) the
  861.     ;processor will jump to the label NMI:
  862.     .dw RESET ;when the processor first turns on or is reset, it will jump
  863.     ;to the label RESET:
  864.     .dw 0 ;external interrupt IRQ is not used in this tutorial
  865.  
  866.  
  867.     ;;;;;;;;;;;;;;
  868.  
  869.  
  870.     .bank 2
  871.     .org $0000
  872.     .incbin "mario.chr" ;includes 8KB graphics file from SMB1
  873.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement