SHARE
TWEET

MyScrollingASM

a guest Dec 21st, 2015 163 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   ; VERT mirroring for HORIZ scrolling
  5.  
  6.  
  7. ;;;;;;;;;;;;;;;
  8.  
  9. ;; DECLARE SOME VARIABLES HERE
  10.   .rsset $0000  ;;start variables at ram location 0
  11.  
  12. scroll          .rs 1  ; horizontal scroll count
  13. nametable       .rs 1  ; which nametable to use, 0 or 1
  14. columnLow       .rs 1  ; low byte of new column address
  15. columnHigh      .rs 1  ; high byte of new column address
  16. sourceLow       .rs 1  ; source for column data
  17. sourceHigh      .rs 1
  18. columnNumber    .rs 1  ; which column of level data to draw
  19.  
  20. partialVariable .rs 1  ; fractional walking speed
  21. isLeft          .rs 1  ; set if facing left
  22. isDescending    .rs 1  ; set if descending
  23. isOnGround:     .rs 1  ; set if on ground
  24.  
  25. ;; DECLARE SOME CONSTANTS HERE
  26.  
  27. GROUND      = $C8
  28. SEMIGROUND  = $C0
  29. TOP_JUMP    = $80
  30.  
  31. MARIO       = $0200
  32.  
  33. ;;;;;;;;;;;;
  34.    
  35.   .bank 0
  36.   .org $C000
  37. RESET:
  38.   SEI          ; disable IRQs
  39.   CLD          ; disable decimal mode
  40.   LDX #$40
  41.   STX $4017    ; disable APU frame IRQ
  42.   LDX #$FF
  43.   TXS          ; Set up stack
  44.   INX          ; now X = 0
  45.   STX $2000    ; disable NMI
  46.   STX $2001    ; disable rendering
  47.   STX $4010    ; disable DMC IRQs
  48.  
  49. vblankwait1:       ; First wait for vblank to make sure PPU is ready
  50.   BIT $2002
  51.   BPL vblankwait1
  52.  
  53. clrmem:
  54.   LDA #$00
  55.   STA $0000, x
  56.   STA $0100, x
  57.   STA $0300, x
  58.   STA $0400, x
  59.   STA $0500, x
  60.   STA $0600, x
  61.   STA $0700, x
  62.   LDA #$FE
  63.   STA $0200, x
  64.   INX
  65.   BNE clrmem
  66.    
  67. vblankwait2:      ; Second wait for vblank, PPU is ready after this
  68.   BIT $2002
  69.   BPL vblankwait2
  70.  
  71.  
  72. LoadPalettes:
  73.   LDA $2002             ; read PPU status to reset the high/low latch
  74.   LDA #$3F
  75.   STA $2006             ; write the high byte of $3F00 address
  76.   LDA #$00
  77.   STA $2006             ; write the low byte of $3F00 address
  78.   LDX #$00              ; start out at 0
  79. LoadPalettesLoop:
  80.   LDA palette, x        ; load data from address (palette + the value in x)
  81.   STA $2007             ; write to PPU
  82.   INX                   ; X = X + 1
  83.   CPX #$20              ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  84.   BNE LoadPalettesLoop  ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  85.                         ; if compare was equal to 32, keep going down
  86.  
  87.  
  88.  
  89. LoadSprites:
  90.   LDX #$00              ; start at 0
  91. LoadSpritesLoop:
  92.   LDA sprites, x        ; load data from address (sprites +  x)
  93.   STA $0200, x          ; store into RAM address ($0200 + x)
  94.   INX                   ; X = X + 1
  95.   CPX #$10              ; Compare X to hex $20, decimal 16
  96.   BNE LoadSpritesLoop   ; Branch to LoadSpritesLoop if compare was Not Equal to zero
  97.                         ; if compare was equal to 16, keep going down
  98.              
  99.              
  100. InitializeNametables:
  101.   LDA #$01
  102.   STA nametable
  103.   LDA #$00
  104.   STA scroll
  105.   STA columnNumber
  106. InitializeNametablesLoop:
  107.   JSR DrawNewColumn     ; draw bg column
  108.   LDA scroll            ; go to next column
  109.   CLC
  110.   ADC #$08
  111.   STA scroll
  112.   INC columnNumber
  113.   LDA columnNumber      ; repeat for first nametable
  114.   CMP #$20
  115.   BNE InitializeNametablesLoop
  116.  
  117.   LDA #$00
  118.   STA nametable
  119.   LDA #$00
  120.   STA scroll
  121.   JSR DrawNewColumn     ; draw first column of second nametable
  122.   INC columnNumber
  123.  
  124.   LDA #$00              ; set back to increment +1 mode
  125.   STA $2000
  126. InitializeNametablesDone:
  127.  
  128.  
  129. InitializeAttributes:
  130.   LDA #$01
  131.   STA nametable
  132.   LDA #$00
  133.   STA scroll
  134.   STA columnNumber
  135. InitializeAttributesLoop:
  136.   JSR DrawNewAttributes     ; draw attribs
  137.   LDA scroll                ; go to next column
  138.   CLC
  139.   ADC #$20
  140.   STA scroll
  141.  
  142.   LDA columnNumber      ; repeat for first nametable
  143.   CLC
  144.   ADC #$04
  145.   STA columnNumber
  146.   CMP #$20
  147.   BNE InitializeAttributesLoop
  148.  
  149.   LDA #$00
  150.   STA nametable
  151.   LDA #$00
  152.   STA scroll
  153.   JSR DrawNewAttributes     ; draw first column of second nametable
  154. InitializeAttributesDone:
  155.  
  156.   LDA #$21
  157.   STA columnNumber
  158.  
  159.              
  160.   LDA #%10010000   ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  161.   STA $2000
  162.  
  163.   LDA #%00011110    ; enable sprites, enable background, no clipping on left side
  164.   STA $2001
  165.  
  166.  
  167.   ;; ----- Initialize variables -----
  168.   LDA #$00
  169.   STA partialVariable
  170.  
  171.   LDA #%00000000
  172.   STA isLeft
  173.  
  174.   LDA #%00000000
  175.   STA isDescending
  176.  
  177.   LDA #%00000001
  178.   STA isOnGround
  179.  
  180. Forever:
  181.   JMP Forever       ; jump back to Forever, infinite loop
  182.  
  183.  
  184.   ;; ----- NMI -----
  185.  
  186. NMI:
  187.  
  188.   LDA #$00
  189.   STA $2003      
  190.   LDA #$02
  191.   STA $4014       ; sprite DMA from $0200
  192.  
  193.   ; run other game graphics updating code here
  194.  
  195.   LDA #$00
  196.   STA $2006        ; clean up PPU address registers
  197.   STA $2006
  198.  
  199.   LDA scroll
  200.   STA $2005        ; write the horizontal scroll count register
  201.  
  202.   LDA #$00         ; no vertical scrolling
  203.   STA $2005
  204.  
  205.  
  206.   ;; ------------------------------------------------------------------------------
  207.   ;; This is the PPU clean up section, so rendering the next frame starts properly.
  208.   ;; ------------------------------------------------------------------------------
  209.  
  210.   LDA #%10010000   ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  211.   ORA nametable    ; select correct nametable for bit 0
  212.   STA $2000
  213.  
  214.   LDA #%00011110   ; enable sprites, enable background, no clipping on left side
  215.   STA $2001
  216.    
  217.   ; run normal game engine code here
  218.   ; reading from controllers, etc
  219.  
  220.   ;; --------------------------------
  221.   ;; ---------- CONTROLLER ----------
  222.   ;; --------------------------------
  223.  
  224.   LatchController:
  225.   LDA #$01
  226.   STA $4016
  227.   LDA #$00
  228.   STA $4016         ;  tell both the controllers to latch buttons
  229.  
  230. ReadA:              ; ----- BUTTON A (JUMP) -----
  231.   LDA $4016         ; player 1 - A
  232.   AND #%00000001    ; only look at bit 0
  233.   BEQ DescendNow    ; branch to DescendNow if button is NOT pressed (0)
  234.                     ; add instructions here to do something when button IS pressed (1)
  235.  
  236.   LDA MARIO
  237.   CMP #TOP_JUMP
  238.   BEQ DescendNow
  239.  
  240.   LDA isDescending
  241.   CMP #%00000001
  242.   BEQ DescendNow
  243.  
  244.   JSR Jump
  245.   LDA #$00
  246.   CMP #$00
  247.   BEQ ReadADone     ; branch always
  248.  
  249. DescendNow:
  250.   LDA MARIO
  251.   CMP #SEMIGROUND
  252.   BEQ JumpDescend
  253.  
  254.   LDA #%00000001
  255.   STA isDescending
  256.  
  257. JumpDescend:
  258.   JSR Descend
  259.  
  260. ReadADone:          ; handling this button is done
  261.  
  262.  
  263.  
  264. ReadB:
  265.   LDA $4016       ; player 1 - B
  266.   AND #%00000001  ; only look at bit 0
  267.   BEQ ReadBDone   ; branch to ReadBDone if button is NOT pressed (0)
  268.                   ; add instructions here to do something when button IS pressed (1)
  269.  
  270. ReadBDone:        ; handling this button is done
  271.  
  272.  
  273. ReadSelect:
  274.   LDA $4016
  275.   AND #%00000001
  276.   BEQ ReadSelectDone
  277.  
  278. ReadSelectDone:
  279.  
  280.  
  281.  
  282. ReadStart:
  283.   LDA $4016
  284.   AND #$00000001
  285.   BEQ ReadStartDone
  286.  
  287. ReadStartDone:
  288.  
  289.  
  290. ReadUp:
  291.   LDA $4016
  292.   AND #$00000001
  293.   BEQ ReadUpDone
  294.  
  295. ReadUpDone:
  296.  
  297.  
  298.  
  299. ReadDown:
  300.   LDA $4016
  301.   AND #%00000001
  302.   BEQ ReadDownDone
  303.  
  304. ReadDownDone:
  305.  
  306.  
  307.  
  308. ReadLeft:               ; ----- LEFT BUTTON -----
  309.   LDA $4016
  310.   AND #%00000001
  311.   BEQ NotWalkingLeft
  312.  
  313.   LDA #%00000001
  314.   STA isLeft            ; left
  315.  
  316.   LDA #$33              ; load walking sprites
  317.   STA $0201
  318.   LDA #$32
  319.   STA $0205
  320.   LDA #$43
  321.   STA $0209
  322.   LDA #$42
  323.   STA $020D
  324.  
  325.   LDA #%01000000       ; unflip
  326.   STA $0202
  327.   STA $0206
  328.   STA $020A
  329.   STA $020E
  330.  
  331.   LDA isOnGround
  332.   CMP #%00000001
  333.   BEQ OnGroundLeft
  334.  
  335.   LDA #$41              ; load jumping sprites
  336.   STA $0201
  337.   LDA #$32
  338.   STA $0205
  339.   LDA #$43
  340.   STA $0209
  341.   LDA #$42
  342.   STA $020D
  343.   LDA #%01000000
  344.   STA $0202
  345.   STA $0206
  346.   STA $020A
  347.   STA $020E
  348.  
  349. OnGroundLeft:
  350.   LDX #$03
  351.   LDY partialVariable
  352.  
  353. ButtonLeftLoop:
  354.   TYA
  355.   SEC
  356.   SBC #$20              ; fractionary speed
  357.   STA partialVariable
  358.   LDA MARIO, X          ; load sprite X position
  359.   SBC #$01              ; integer speed
  360.   STA MARIO, X          ; save sprite X position
  361.   INX
  362.   INX
  363.   INX
  364.   INX
  365.   CPX #$13
  366.   BNE ButtonLeftLoop
  367.  
  368.   LDA #$00
  369.   CMP #$00
  370.   BEQ ReadLeftDone      ; branch always
  371.  
  372. NotWalkingLeft:         ; only when on ground and left
  373.  
  374.   LDA isOnGround
  375.   CMP #%00000001
  376.   BNE ReadLeftDone
  377.  
  378.   LDA isLeft
  379.   CMP #%00000001
  380.   BNE ReadLeftDone
  381.  
  382.   LDA #$33              ; load static left sprites
  383.   STA $0201
  384.   LDA #$32
  385.   STA $0205
  386.   LDA #$4F
  387.   STA $0209
  388.   STA $020D
  389.  
  390.   LDA #%0000000       ; flip
  391.   STA $020A
  392.   LDA #%01000000
  393.   STA $0202
  394.   STA $0206
  395.   STA $020E
  396.  
  397. ReadLeftDone:
  398.  
  399.  
  400.  
  401.  
  402. ReadRight:              ; ----- RIGHT BUTTON -----
  403.   LDA $4016
  404.   AND #$00000001
  405.   BEQ NotWalkingRight
  406.  
  407.   ; background scrolling
  408.   JSR Scrolling
  409.  
  410.   ; MARIO ACTIONS
  411.  
  412.   LDA #%00000000
  413.   STA isLeft            ; not left
  414.  
  415.   LDA #$32              ; load walking sprites
  416.   STA $0201
  417.   LDA #$33
  418.   STA $0205
  419.   LDA #$42
  420.   STA $0209
  421.   LDA #$43
  422.   STA $020D
  423.  
  424.   LDA #%00000000       ; unflip
  425.   STA $0202
  426.   STA $0206
  427.   STA $020A
  428.   STA $020E
  429.  
  430.   LDA isOnGround
  431.   CMP #%00000001
  432.   BEQ OnGroundRight
  433.  
  434.   LDA #$32              ; load jumping sprites
  435.   STA $0201
  436.   LDA #$41
  437.   STA $0205
  438.   LDA #$42
  439.   STA $0209
  440.   LDA #$43
  441.   STA $020D
  442.   LDA #%00000000
  443.   STA $0202
  444.   STA $0206
  445.   STA $020A
  446.   STA $020E
  447.  
  448.  
  449. OnGroundRight:
  450.   LDX #$03
  451.   LDY partialVariable
  452.  
  453. ButtonRightLoop:
  454.   TYA
  455.   CLC
  456.   ADC #$20              ; fractionary speed
  457.   STA partialVariable
  458.   LDA MARIO, X          ; load sprite X position
  459.   ADC #$01              ; integer speed
  460.   STA MARIO, X          ; save sprite X position
  461.   INX
  462.   INX
  463.   INX
  464.   INX
  465.   CPX #$13
  466.   BNE ButtonRightLoop
  467.  
  468.   LDA #$00
  469.   CMP #$00
  470.   BEQ ReadRightDone     ; branch always
  471.  
  472.  
  473. NotWalkingRight:        ; only when on ground and not left
  474.  
  475.   LDA isOnGround
  476.   CMP #%00000001
  477.   BNE ReadRightDone
  478.  
  479.   LDA isLeft
  480.   CMP #%00000001
  481.   BEQ ReadRightDone
  482.  
  483.   LDA #$32              ; load static sprites
  484.   STA $0201
  485.   LDA #$33
  486.   STA $0205
  487.   LDA #$4F
  488.   STA $0209
  489.   STA $020D
  490.  
  491.   LDA #%00000000       ; unflip
  492.   STA $0202
  493.   STA $0206
  494.   STA $020A
  495.   LDA #%01000000
  496.   STA $020E
  497.  
  498. ReadRightDone:
  499.  
  500.   RTI              ; return from interrupt
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.   ;; ---------------------------------
  510.   ;; ---------- SUBROUTINES ----------
  511.   ;; ---------------------------------
  512.  
  513.   ;; ----- SCROLLING -----
  514.  
  515. Scrolling:
  516.  
  517.   INC scroll
  518.  
  519. NTSwapCheck:
  520.   LDA scroll            ; check if the scroll just wrapped from 255 to 0
  521.   BNE NTSwapCheckDone  
  522. NTSwap:
  523.   LDA nametable         ; load current nametable number (0 or 1)
  524.   EOR #$01              ; exclusive OR of bit 0 will flip that bit
  525.   STA nametable         ; so if nametable was 0, now 1
  526.                         ;    if nametable was 1, now 0
  527. NTSwapCheckDone:
  528.  
  529. NewAttribCheck:
  530.   LDA scroll
  531.   AND #%00011111            ; check for multiple of 32
  532.   BNE NewAttribCheckDone    ; if low 5 bits = 0, time to write new attribute bytes
  533.   jsr DrawNewAttributes
  534. NewAttribCheckDone:
  535.  
  536. NewColumnCheck:
  537.   LDA scroll
  538.   AND #%00000111            ; throw away higher bits to check for multiple of 8
  539.   BNE NewColumnCheckDone    ; done if lower bits != 0
  540.   JSR DrawNewColumn         ; if lower bits = 0, time for new column
  541.  
  542.   lda columnNumber
  543.   clc
  544.   adc #$01             ; go to next column
  545.   and #%01111111       ; only 128 columns of data, throw away top bit to wrap
  546.   sta columnNumber
  547. NewColumnCheckDone:
  548.  
  549.   RTS
  550.  
  551. DrawNewColumn:
  552.   LDA scroll       ; calculate new column address using scroll register
  553.   LSR A
  554.   LSR A
  555.   LSR A            ; shift right 3 times = divide by 8
  556.   STA columnLow    ; $00 to $1F, screen is 32 tiles wide
  557.  
  558.   LDA nametable     ; calculate new column address using current nametable
  559.   EOR #$01          ; invert low bit, A = $00 or $01
  560.   ASL A             ; shift up, A = $00 or $02
  561.   ASL A             ; $00 or $04
  562.   CLC
  563.   ADC #$20          ; add high byte of nametable base address ($2000)
  564.   STA columnHigh    ; now address = $20 or $24 for nametable 0 or 1
  565.  
  566.   LDA columnNumber  ; column number * 32 = column data offset
  567.   ASL A
  568.   ASL A
  569.   ASL A
  570.   ASL A
  571.   ASL A            
  572.   STA sourceLow
  573.   LDA columnNumber
  574.   LSR A
  575.   LSR A
  576.   LSR A
  577.   STA sourceHigh
  578.  
  579.   LDA sourceLow       ; column data start + offset = address to load column data from
  580.   CLC
  581.   ADC #LOW(columnData)
  582.   STA sourceLow
  583.   LDA sourceHigh
  584.   ADC #HIGH(columnData)
  585.   STA sourceHigh
  586.  
  587. DrawColumn:
  588.   LDA #%00000100        ; set to increment +32 mode
  589.   STA $2000
  590.  
  591.   LDA $2002             ; read PPU status to reset the high/low latch
  592.   LDA columnHigh
  593.   STA $2006             ; write the high byte of column address
  594.   LDA columnLow
  595.   STA $2006             ; write the low byte of column address
  596.   LDX #$1E              ; copy 30 bytes
  597.   LDY #$00
  598. DrawColumnLoop:
  599.   LDA [sourceLow], y
  600.   STA $2007
  601.   INY
  602.   DEX
  603.   BNE DrawColumnLoop
  604.  
  605.   RTS
  606.  
  607.  
  608. DrawNewAttributes:
  609.   LDA nametable
  610.   EOR #$01          ; invert low bit, A = $00 or $01
  611.   ASL A             ; shift up, A = $00 or $02
  612.   ASL A             ; $00 or $04
  613.   CLC
  614.   ADC #$23          ; add high byte of attribute base address ($23C0)
  615.   STA columnHigh    ; now address = $23 or $27 for nametable 0 or 1
  616.  
  617.   LDA scroll
  618.   LSR A
  619.   LSR A
  620.   LSR A
  621.   LSR A
  622.   LSR A
  623.   CLC
  624.   ADC #$C0
  625.   STA columnLow     ; attribute base + scroll / 32
  626.  
  627.   LDA columnNumber  ; (column number / 4) * 8 = column data offset
  628.   AND #%11111100
  629.   ASL A
  630.   STA sourceLow
  631.   LDA columnNumber
  632.   LSR A
  633.   LSR A
  634.   LSR A
  635.   LSR A
  636.   LSR A
  637.   LSR A
  638.   LSR A
  639.   STA sourceHigh
  640.  
  641.   LDA sourceLow       ; column data start + offset = address to load column data from
  642.   CLC
  643.   ADC #LOW(attribData)
  644.   STA sourceLow
  645.   LDA sourceHigh
  646.   ADC #HIGH(attribData)
  647.   STA sourceHigh
  648.  
  649.   LDY #$00
  650.   LDA $2002             ; read PPU status to reset the high/low latch
  651. DrawNewAttributesLoop
  652.   LDA columnHigh
  653.   STA $2006             ; write the high byte of column address
  654.   LDA columnLow
  655.   STA $2006             ; write the low byte of column address
  656.   LDA [sourceLow], y    ; copy new attribute byte
  657.   STA $2007
  658.  
  659.   INY
  660.   CPY #$08              ; copy 8 attribute bytes
  661.   BEQ DrawNewAttributesLoopDone
  662.  
  663.   LDA columnLow         ; next attribute byte is at address + 8
  664.   CLC
  665.   ADC #$08
  666.   STA columnLow
  667.   JMP DrawNewAttributesLoop
  668. DrawNewAttributesLoopDone:
  669.  
  670.   RTS
  671.  
  672.  
  673.   ;; ----- MARIO ACTIONS -----
  674.  
  675. Jump:
  676.  
  677.   LDA #%00000000
  678.   STA isOnGround        ; false
  679.  
  680.   LDA #$32              ; load right sprites
  681.   STA $0201
  682.   LDA #$41
  683.   STA $0205
  684.   LDA #$42
  685.   STA $0209
  686.   LDA #$43
  687.   STA $020D
  688.   LDA #%00000000
  689.   STA $0202
  690.   STA $0206
  691.   STA $020A
  692.   STA $020E
  693.  
  694.   LDA isLeft
  695.   CMP #%00000001
  696.   BNE NotLeft
  697.  
  698.   LDA #$41              ; load left sprites
  699.   STA $0201
  700.   LDA #$32
  701.   STA $0205
  702.   LDA #$43
  703.   STA $0209
  704.   LDA #$42
  705.   STA $020D
  706.   LDA #%01000000
  707.   STA $0202
  708.   STA $0206
  709.   STA $020A
  710.   STA $020E
  711.  
  712. NotLeft:
  713.   LDA MARIO
  714.   CMP #TOP_JUMP
  715.   BEQ Return
  716.  
  717.   LDX #$00
  718. SpriteUpLoop:
  719.   LDA MARIO, x    ; load sprite Y position
  720.   SEC             ; make sure carry flag is set
  721.   SBC #$02        ; jump speed
  722.   STA MARIO, x    ; save sprite Y position
  723.   INX
  724.   INX
  725.   INX
  726.   INX
  727.   CPX #$10
  728.   BNE SpriteUpLoop
  729.  
  730. Return:
  731.   RTS
  732.  
  733.  
  734. Descend:
  735.  
  736.   LDA isOnGround
  737.   CMP #%00000001
  738.   BEQ DescendReturn
  739.  
  740. StepDown:
  741.   LDX #$00
  742. SpriteDownLoop:
  743.   LDA MARIO, x    ; load sprite Y position
  744.   CLC             ; make sure carry flag is clear
  745.   ADC #$02        ; descend speed
  746.   STA MARIO, x    ; save sprite Y position
  747.   INX
  748.   INX
  749.   INX
  750.   INX
  751.   CPX #$10
  752.   BNE SpriteDownLoop
  753.   ;JSR vblankwait
  754.  
  755.   LDA MARIO
  756.   CMP #SEMIGROUND
  757.   BNE DescendReturn
  758.  
  759.   JSR OnGround
  760.  
  761. DescendReturn
  762.   RTS
  763.  
  764.  
  765. OnGround:
  766.   LDA #%00000001
  767.   STA isOnGround        ; true
  768.  
  769.   LDA #%00000000
  770.   STA isDescending      ;false
  771.  
  772.   LDA #$32              ; restore right sprites
  773.   STA $0201
  774.   LDA #$33
  775.   STA $0205
  776.   LDA #$4F
  777.   STA $0209
  778.   STA $020D
  779.   LDA #%00000000
  780.   STA $0202
  781.   STA $0206
  782.   STA $020A
  783.   LDA #%01000000
  784.   STA $020E
  785.  
  786.   LDA isLeft
  787.   CMP #%00000001
  788.   BNE NotDescending
  789.  
  790.   LDA #$33              ; restore left sprites
  791.   STA $0201
  792.   LDA #$32
  793.   STA $0205
  794.   LDA #$4F
  795.   STA $0209
  796.   STA $020D
  797.   LDA #%01000000
  798.   STA $0202
  799.   STA $0206
  800.   STA $020E
  801.   LDA #%00000000
  802.   STA $020A
  803.  
  804. NotDescending:
  805.   LDA #%00000000
  806.   STA isDescending
  807.   RTS
  808.  
  809.  
  810. ;;;;;;;;;;;;;;  
  811.  
  812.   .bank 1
  813.   .org $E000
  814. palette:
  815.   .db $22,$29,$1A,$0F,  $22,$36,$17,$0F,  $22,$30,$21,$0F,  $22,$27,$17,$0F   ;;background palette
  816.   .db $22,$16,$27,$18,  $22,$1A,$30,$27,  $22,$16,$30,$27,  $22,$0F,$36,$17   ;;sprite palette
  817.  
  818. sprites:
  819.      ;vert        tile attr horiz
  820.   .db SEMIGROUND, $32, $00, $40   ;sprite 0
  821.   .db SEMIGROUND, $33, $00, $48   ;sprite 1
  822.   .db GROUND,     $4F, $00, $40   ;sprite 2
  823.   .db GROUND,     $4F, $40, $48   ;sprite 3
  824.  
  825.  
  826. columnData:
  827.   .incbin "SMBlevel.bin"
  828.  
  829. attribData:
  830.   .incbin "SMBattrib.bin"
  831.  
  832.   .org $FFFA     ;first of the three vectors starts here
  833.   .dw NMI        ;when an NMI happens (once per frame if enabled) the
  834.                    ;processor will jump to the label NMI:
  835.   .dw RESET      ;when the processor first turns on or is reset, it will jump
  836.                    ;to the label RESET:
  837.   .dw 0          ;external interrupt IRQ is not used in this tutorial
  838.  
  839.  
  840. ;;;;;;;;;;;;;;  
  841.  
  842.  
  843.   .bank 2
  844.   .org $0000
  845.   .incbin "mario.chr"   ;includes 8KB graphics file from SMB1
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