Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .enum $0000 ;;start variables at ram location 0
- spritenumber .dsb 1
- newbuttons .dsb 1
- oldbuttons .dsb 1
- justpressed .dsb 1
- tempval .dsb 1
- gamestate .dsb 1
- titlespritesloadcheck .dsb 1
- cursorx .dsb 1
- cursory .dsb 1
- piclo .dsb 1
- pichi .dsb 1
- spriteclearcounter .dsb 1
- textstring .dsb 32
- stringlocation .dsb 1
- lobyte .dsb 1
- hibyte .dsb 1
- screennumber .dsb 1
- oldscreen .dsb 1
- loopgap .dsb 1
- looplength .dsb 1
- spritedir .dsb 1
- spritedirpointer .dsb 2
- ;variables for scrollnes routine
- scroll_h .dsb 1
- scroll_v .dsb 1
- sspeed .dsb 1
- offset_counter .dsb 1
- char_counter .dsb 1
- char_address .dsb 1 ; Points to beginning of desired character memory
- write_width .dsb 1
- size_toggle .dsb 1 ; 8x8 or 16x8
- char_val .dsb 1 ; tile 0,1,2,3
- size .dsb 1
- char .dsb 1
- speed_toggle .dsb 1
- currentvirtpos .dsb 1
- framenumber .dsb 1
- virtcounter .dsb 1
- virtnumber .dsb 1
- ppumask .dsb 1
- textstringcounter .dsb 1
- prescrollcleanup .dsb 1
- clearflag .dsb 1
- scrollspritesloadcheck .dsb 1
- spriteanimationcounter .dsb 1
- spriteanimationnumber .dsb 1
- .ende
- spriteram = $0200
- statetitle = $0
- stateplay = $1
- leftwall = $00
- rightwall = $f0
- topwall = $7f
- bottomwall = $cf
- ; ----------------------------------------------------
- .ORG $7ff0
- Header: ; 16 byte .NES header (iNES format)
- .DB "NES", $1a
- .DB $02 ; size of PRG ROM in 16kb units
- .DB $01 ; size of CHR ROM in 8kb units
- .DB #%00000000 ; mapper 0
- .DB #%00000000 ; mapper 0
- .DB $00
- .DB $00
- .DB $00
- .DB $00
- .DB $00
- .DB $00
- .DB $00
- .DB $00
- .ORG $8000
- ;----reset routine----
- Reset: ; reset routine
- sei ; disable IRQs
- cld ; disable decimal mode
- ldx #$40
- stx $4017 ; disable APU frame IRQ
- ldx #$FF
- txs ; Set up stack
- inx ; now X = 0
- stx $2000 ; disable NMI
- stx $2001 ; disable rendering
- stx $4010 ; disable DMC IRQs
- clrmem: ; As it says, clears the RAM
- lda #$00
- sta $0000, x
- sta $0100, x
- sta $0300, x
- sta $0400, x
- sta $0500, x
- sta $0600, x
- sta $0700, x
- lda #$FE ; Sprite RAM needs $FE so that all sprites are off screen until set
- sta $0200, x
- inx
- bne clrmem
- ldx #$00
- ldy #$10
- ClearPPU sta $2007
- dex
- bne ClearPPU
- dey
- bne ClearPPU
- lda #$00
- sta $2003
- tay
- ClearSpr sta $2004
- dey
- bne ClearSpr
- ;----setting up variables----
- lda #$00
- sta spriteclearcounter
- sta titlespritesloadcheck
- sta stringlocation
- sta textstring
- STA scroll_h
- STA scroll_v
- STA offset_counter
- STA char_counter
- STA write_width
- STA char
- STA size_toggle
- STA size
- STA currentvirtpos
- sta framenumber
- sta clearflag
- sta prescrollcleanup
- sta oldscreen
- sta tempval
- sta screennumber
- sta scrollspritesloadcheck
- sta spritedir
- sta spritenumber
- STA textstringcounter
- lda #01
- STA sspeed
- STA speed_toggle
- lda #1
- sta virtcounter
- sta virtnumber
- lda #10 ;higher/lower number = longer / shorter gap before text loop
- sta loopgap
- LDA #$30 ;higher/lower number = faster/slower animation
- STA spriteanimationcounter
- STA spriteanimationnumber
- lda #$00
- sta cursorx
- lda #$7f
- sta cursory
- lda #$f0
- STA char_val
- lda #$20
- sta lobyte
- lda #$e0
- sta hibyte
- lda #statetitle
- sta gamestate
- ;----warm up----
- ldx #$02
- WarmUp:
- BIT $2002
- BPL WarmUp
- DEX
- bne WarmUp
- lda #$3F
- sta $2006
- lda #$00
- sta $2006
- TAX
- LoadPal: ;
- lda palette, x
- sta $2007
- INX
- CPX #$20
- bne LoadPal
- lda #$20
- sta $2006
- lda #$00
- sta $2006
- ; jsr clearnametable
- ;----Pre Vblank----
- ;----load title screen----
- lda #<titlescreen ; load low byte of
- sta piclo ; store it in the piclo variable
- lda #>titlescreen ; load high byte of first picture
- sta pichi ; store it in the pichi variable
- jsr drawscreen ; draw the screen we just loaded
- ;----move all 64 sprites off screen----
- jsr movespritesoffscreen ; move all the sprites off screen
- jsr vblank ; turn on screen
- ;----infinite loop: program now controlled by NMI routine----
- infloop:
- jmp infloop
- jsr scroll ; jump to scroll sub routine
- scrolldone:
- ;----NMI----
- NMI:
- jsr controllertest ; check for user input
- gameengine:
- lda gamestate ; load the current game state
- cmp #statetitle ; check and see if it is the title state
- beq enginestatetitle ; if so jump to the title engine state
- lda gamestate ; if not load the current game state
- cmp #stateplay ; check and see if it is the play state
- beq enginestateplay ; if so jump to the play engine state
- gameenginedone:
- RTI
- IRQ:
- RTI
- ;----------------------------------------------------
- controllertest: ;button ( 0 0 0 0 0 0 0 0 )
- lda newbuttons ;layout ( R L D U St Sl B A )
- sta oldbuttons
- ldx #$00
- lda #$01 ; strobe joypad
- sta $4016
- lda #$00
- sta $4016
- ConLoop:
- lda $4016 ; check the state of each button
- LSR
- ROR newbuttons
- INX
- CPX #$08
- bne ConLoop
- lda oldbuttons ; invert bits
- EOR #$FF
- and newbuttons
- sta justpressed
- rts
- ;----gameengine----
- enginestatetitle:
- lda titlespritesloadcheck ; check to see if we need to load the title screen sprites
- bne skiptitlespriteload ; if we have, skip loading them again
- jsr loadtitlesprites ; jump to the load title sprites routine
- skiptitlespriteload:
- jsr titlecontrols ; read the controls for the title states
- jsr updatecursorsprite ; update the cursor sprite
- jsr updatesprites ; transfer the sprites to ram
- lda #00 ; load #00 to A
- sta $2005 ; write twice to $2005
- sta $2005 ; to confirm no scrolling in this state.
- jmp gameenginedone ; game engine complete for this frame
- enginestateplay:
- lda prescrollcleanup ; load pre scroll cleanup flag
- cmp #01 ; check if we have cleaned up the screen the frame before starting the scroll routine
- beq skipprescrollcleanup ; skip cleanup if we have done it already
- jsr movespritesoffscreen ; move all the sprites of screen
- jsr loadblankscreen ; load a blank screen or our title screen will scroll which would suck.
- jsr drawscreen ; draw the blank screen
- jsr vblank ; vblank
- lda #01 ; set the pre scroll clean up flag
- sta prescrollcleanup ; store it so we skip this next time.
- skipprescrollcleanup:
- jsr playcontrols ; load the play state controls
- JSR virtscroll ; update vertical scrolling (sin up / down)
- JSR horizscroll
- lda #%10001100
- sta $2000
- lda scrollspritesloadcheck ; check if we have loaded the play state sprites
- cmp #01
- beq skipscrollspriteload ; if we have, skip loading them
- jsr loadscrollsprites ; load playstate sprites
- skipscrollspriteload:
- jsr animatesprites ; check if we need to animate sprites thie frame
- jsr changesprites ; if so, change them
- jsr spritemovecheck ; check if we need to move sprites this frame
- jsr updatesprites ; write sprites to ram
- jmp gameenginedone ; game engine complete.
- ;----sub routines----------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------------------------
- vblank:
- BIT $2002 ; vblank
- BPL vblank
- lda #%10000100
- sta $2000
- lda #%00011110
- sta $2001
- sta ppumask
- rts
- loadtitlesprites:
- lda cursory ; load cursor y position
- sta $0200 ; store it in y pos for sprite 1
- lda #tempval ; load tempval
- sta $0201 ; store in tile pos for sprite 1
- lda #$00 ; load attribute $00
- sta $0202 ; store in attribute pos for sprite 1
- lda cursorx ; load cursor x position
- sta $0203 ; store in x pos for sprite 1
- lda #01 ; load #01 to a
- sta titlespritesloadcheck ; store in loadcheck flag so we only do this once
- rts
- updatecursorsprite:
- lda tempval ; load current tempval
- sta $0201 ; store in tile pos for sprite 1
- rts
- titlecontrols:
- checkup:
- lda #%00010000 ; check if up was pressed
- and justpressed
- beq checkdown ; if not skip this button and check down
- lda cursory ; load cursory position
- cmp #topwall ; compare to #topwall (the top row of letters)
- beq checkdown ; if = skip this button and check down
- lda spriteram ; load value in spriteram 0
- sec ; set the carry flag
- sbc #$10 ; subtract $10
- sta spriteram ; store in spriteram 0
- sta cursory ; and cursory position
- lda tempval ; load tempval
- sec ; set the carry flag
- sbc #$10 ; subtract $10
- sta tempval ; store in tempval
- checkdown:
- lda #%00100000 ; check down/left/right follow the same pattern
- and justpressed
- beq checkleft
- lda cursory
- cmp #bottomwall
- beq checkleft
- lda spriteram
- clc
- adc #$10
- sta spriteram
- sta cursory
- lda tempval
- CLC
- adc #$10
- sta tempval
- checkleft:
- lda #%01000000
- and justpressed
- beq checkright
- lda cursorx
- cmp #leftwall
- beq checkright
- lda spriteram+3
- sec
- sbc #$10
- sta spriteram+3
- sta cursorx
- lda tempval
- sec
- sbc #$01
- sta tempval
- checkright:
- lda #%10000000
- and justpressed
- beq checkselect
- lda cursorx
- cmp #rightwall
- beq checkselect
- lda spriteram+3
- clc
- adc #$10
- sta spriteram+3
- sta cursorx
- lda tempval
- CLC
- adc #$01
- sta tempval
- checkselect: ; this button doesn't do anything
- lda #%00000100
- and justpressed
- beq checkstart
- checkstart:
- lda #%00001000 ; check if start was pressed
- and justpressed
- beq checkb ; if not skip this button and check b
- lda #stateplay ; load #stateplay
- sta gamestate ; store in gamestate (tell engine start scrolling)
- lda #01 ; load #01
- sta screennumber ; store in screen number to start scrolling with blank screen in the background rather than the title screen
- lda stringlocation ; load the current stringlocation ("test" is 4 letters for stringlocation is 4
- adc loopgap ; add the string location to the loop gap (if stringlocation is 4 and loopgap is 3 we have 7)
- sta looplength ; store the total in looplength
- checkb:
- lda #%00000010 ; check is b was pressed
- and justpressed
- beq checka ; if not skip this button and check a
- lda stringlocation ; load the current string location
- cmp #$20 ; compare it to #$20 (32 letters=full string)
- beq checka ; if = skip this button and check a
- lda stringlocation ; load the current string location
- cmp #$10 ; compare to $10 (the first row of letters is 16 letters long, if we are on string location $10 we need to move to the next row of letters)
- bne skipline2increment ; if not $10 yet, don't move to 2nd line
- lda #$21 ; if $10 load $21
- sta lobyte ; store it in the lobyte screen location
- lda #$20 ; then load $20
- sta hibyte ; store it in the hibyte screen location, this starts entering text back at the beginning of the first line.
- skipline2increment
- lda lobyte ; load the current lobyte
- sta $2006 ; write it to $2006
- lda hibyte ; load the current hibyte
- sta $2006 ; store it to $2006
- lda tempval ; load tempval (if tempval = $00 display a space)
- sta $2007 ; store it in $2007
- ldx stringlocation ; load to x the current stringlocation
- sta textstring,x ; store tempval in textstring at location X, for example if we want to write "test" and the cursor is on lower case "t" tempval will be $54. If this is the first character we enter, stringlocation will be $00 so we store it in location $00 of textext string
- inc stringlocation ; stringlocation +1, next time we run this routine we will load the next string location
- inc hibyte ; increment the hibyte
- inc hibyte ; do it again to display the next character 2 spaces to the right.
- checka: ; delete one character
- lda #%00000001
- and justpressed ; check if A was pressed
- beq titlecontrolsdone ; if not, handling A is done
- lda stringlocation ; load string location
- cmp #$00 ; check is the string is at #$00 (empty string = nothing to delete)
- beq titlecontrolsdone ; if string = #$00 handling A is done
- lda stringlocation ; load string location
- cmp #$10 ; check if it is #$10 (16th character) if it is, we need to move to the top line of characters on the title screeen.
- bne skipline2decrement ; if not #$11 skip code to move to top line
- lda #$20 ; load #$20 (top "slice" of the background)
- sta lobyte ; store it in the lobyte
- lda #$fe ; load #$fe (far right top line space)
- sta hibyte ; store it in the hibyte
- jmp skipdecrement ; we hardwrote the location for the far right of the top line so we don't need to decrement the hibyte in this case
- skipline2decrement
- dec hibyte ; subtract 1 from the high byte
- dec hibyte ; subtract 1 from the high byte
- skipdecrement
- lda lobyte
- sta $2006
- lda hibyte
- sta $2006
- lda $00 ; load tile $00 (blank tile)
- sta $2007
- dec stringlocation ; subtract 1 from the string location
- ldx stringlocation ; load the string location into x
- sta textstring,x
- titlecontrolsdone:
- rts
- ;----play state controls----
- playcontrols:
- heldchecks:
- LDA #%00000010 ;check if b is held
- AND newbuttons
- BEQ aheld
- LDA #%00000001 ;check if a is held
- AND newbuttons
- BEQ bheld
- JSR baheldchecks ;check if a and b are held
- JMP checksdone
- bheld:
- JSR bheldchecks
- JMP checksdone
- aheld:
- LDA #%00000001 ;check if a is held
- AND newbuttons
- BEQ nothingheld
- JSR aheldchecks
- JMP checksdone
- nothingheld:
- JSR nothingheldchecks
- JMP checksdone
- checksdone:
- rts
- baheldchecks
- rts
- bheldchecks
- rts
- nothingheldchecks:
- playcheckup:
- lda #%00010000
- and justpressed
- beq playcheckdown
- LDA #1
- STA size_toggle
- playcheckdown:
- lda #%00100000
- and justpressed
- beq playcheckleft
- LDA #0
- STA size_toggle
- playcheckleft:
- lda #%01000000
- and justpressed
- beq playcheckright
- lda #01
- sta speed_toggle
- playcheckright:
- lda #%10000000
- and justpressed
- beq playcheckselect
- lda #00
- sta speed_toggle
- playcheckselect:
- lda #%00000100
- and justpressed
- beq playcheckstart
- INC char_val
- INC char_val
- LDA char_val
- cmp #$Fe
- BNE playcheckstart
- LDA #$f0
- STA char_val
- playcheckstart:
- lda #%00001000
- and justpressed
- beq playchecksdone
- LDA #%00001000 ;toggle sprites on/off
- eor ppumask
- STA $2001
- sta ppumask
- playchecksdone:
- rts
- aheldchecks:
- aplaycheckup:
- lda #%00010000
- and justpressed
- beq aplaycheckdown
- LDA #0
- STA spritedir
- aplaycheckdown:
- lda #%00100000
- and justpressed
- beq aplaycheckleft
- LDA #1
- STA spritedir
- aplaycheckleft:
- lda #%01000000
- and justpressed
- beq aplaycheckright
- lda #2
- sta spritedir
- aplaycheckright:
- lda #%10000000
- and justpressed
- beq aplaycheckselect
- lda #3
- sta spritedir
- aplaycheckselect:
- lda #%00000100
- and justpressed
- beq aplaycheckstart
- ldx #0 ; this code can be used to move
- - ; sprites to fore / back ground
- lda #%00100000
- eor spriteram+2,x
- sta $202,x
- sta spriteram+2,x
- inx
- inx
- inx
- inx
- bne -
- aplaycheckstart:
- lda #%000001000
- and justpressed
- beq aplaychecksdone
- LDA #%00010000 ;toggle sprites on/off
- eor ppumask
- STA $2001
- sta ppumask
- aplaychecksdone
- rts
- scroll:
- Vblank: ; turn on the screen
- BIT $2002
- BPL Vblank
- LDX scroll_h
- STX $2005
- LDX scroll_v
- STX $2005
- LDA #%1001100
- STA $2000
- LDA #%00011110
- STA $2001
- STA ppumask
- RTS
- ; ----------------------------------------------------
- ; a huge section of the drawloop routine is directly from scrollnes.
- DrawLoop: ;** CALCULATE CHARACTER ADDRESS
- LDX size_toggle ; Change size, speed and character set after string loops
- STX size
- LDX char_val
- STX char
- LDX speed_toggle
- STX sspeed
- LDX textstringcounter
- ; Determine high address
- LDA textstring,x ; or whatever your text string is
- LSR ; Divide by 4 (Shift right 2 times)
- LSR
- CLC
- ADC #$C0 ; Add #$c0 to result to start at bank $c000 where the bin file is
- STA char_address+1
- ;Determine low address
- LDA textstring,x ; or whatever your text string is
- ASL ; Multiply by 64 (Shift left 6 times)
- ASL
- ASL
- ASL
- ASL
- ASL
- STA char_address+0
- LDA textstringcounter
- CMP looplength
- BNE noreset
- LDA #$00
- STA textstringcounter
- noreset:
- ; Final result $C000 -> $C040 -> $C080 -> $C0C0 -> $C100 AND so on
- ; ----------------------------------------------------
- LDX offset_counter
- LDY offset_table,x
- LDA #$20
- STA $2006
- STY $2006
- LDX #8
- ReadChar:
- LDY char_counter
- LDA (char_address),y ; Use post-address indexing to use full memory address
- CLC
- ADC char
- STA $2007
- TAY
- LDA size ; Check status of size variable to decide if there should be an extra write
- BEQ small
- STY $2007
- small:
- INC char_counter
- DEX
- BNE ReadChar
- LDA char_counter ; Do not exceed 64 (8x8->length of character)
- AND #$3f
- STA char_counter
- BNE SkipInc ; While we're here, Increment the string position if the result is zero
- inc textstringcounter
- SkipInc:
- RTS
- ; ----------------------------------------------------
- EraseInit:
- INC offset_counter
- LDA offset_counter
- CMP #32
- BNE EraseColumn
- LDA #0
- STA offset_counter
- EraseColumn:
- LDX offset_counter
- LDY offset_table,x ; Use offset table to calculate screen position
- LDA #$20
- STA $2006
- STY $2006
- LDX #16
- EraseLoop:
- LDA #$00 ; Write blank tile (erase)
- STA $2007
- DEX ; 16x to cover height of character
- BNE EraseLoop
- RTS
- virtscroll:
- DEC virtcounter
- BNE novirt
- LDX framenumber
- LDA virtpos,x
- STA scroll_v
- inc framenumber
- LDA framenumber
- cmp #$80
- BNE noresetframe
- LDA #$00
- STA framenumber
- noresetframe
- LDA virtnumber
- STA virtcounter
- novirt:
- RTS
- horizscroll:
- INC scroll_h ; Update scroll counters
- INC scroll_h
- LDA sspeed
- BEQ SlowScroll
- INC scroll_h
- INC scroll_h
- SlowScroll:
- LDA scroll_h
- AND #$07
- BNE KeepGoing
- JSR DrawLoop
- JSR EraseInit
- KeepGoing:
- LDX scroll_h ; Update scroll registers
- STX $2005
- LDX scroll_v
- STX $2005
- RTS
- clearnametable:
- LDY #$04 ; clear nametables
- clearname:
- ldx #$00
- lda #$00
- ppuloop:
- sta $2007
- DEX
- bne ppuloop
- DEY
- bne clearname
- rts
- ;----movesprites off screen----
- movespritesoffscreen:
- lda #$ff
- ldx #$00
- -
- sta spriteram,x ;copy to RAM
- inx
- bne -
- rts
- drawscreen:
- lda #$20 ; set to beginning of first nametable
- sta $2006
- lda #$00
- sta $2006
- LDY #$00
- ldx #$04
- nameloop: ;loop to draw entire nametable
- lda (piclo),y
- sta $2007
- INY
- bne nameloop
- inc pichi
- DEX
- bne nameloop
- rts
- loadblankscreen:
- LDA #%00000000 ; disable NMI's and screen display
- STA $2000
- LDA #%00000000
- STA $2001
- lda #<blank ; load low byte of
- sta piclo
- lda #>blank ; load high byte of first picture
- sta pichi
- rts
- loadscrollsprites:
- LDX #$00 ; start at 0
- loadscrollspritesloop
- LDA sprites, x ; load data from address (sprites + x)
- STA spriteram, x ; store into RAM address ($0200 + x)
- INX ; X = X + 1
- CPX #$00 ; Compare X to hex $ff, decimal 64
- BNE loadscrollspritesloop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
- lda #01
- sta scrollspritesloadcheck
- rts
- ;----sprite update subroutine start----
- updatesprites:
- lda #$00
- sta $2003 ; low byte (00) of RAM address
- lda #$02
- sta $4014 ; high byte (02) of RAM address, start transfer
- rts
- ;------------------------------
- ; Sprite move subroutines start
- spritemovecheck:
- lda spritedir ; load the screen number
- asl a ; x2 for word indexing
- tax ; use the game screen # as our index
- lda loadspritedir,x ; store the screennumber as a pointer.
- sta spritedirpointer
- lda loadspritedir+1,x
- sta spritedirpointer+1
- jmp (spritedirpointer)
- rts ; back to normal program flow
- playup:
- LDX #0
- LDY #0
- @loop
- CLC
- LDA spriteram,x
- SBC speed,y
- STA spriteram,x
- STA $0200,x
- INY
- cpy #4
- BNE @skipreset
- LDY #0
- @skipreset
- INX
- INX
- INX
- INX
- CPX #0
- BNE @loop
- RTS
- playdown:
- LDX #0
- LDY #0
- @loop
- CLC
- LDA spriteram,x
- ADC speed,y
- STA spriteram,x
- STA $0200,x
- INY
- cpy #4
- BNE @skipreset
- LDY #0
- @skipreset
- INX
- INX
- INX
- INX
- CPX #0
- BNE @loop
- RTS
- playright:
- LDX #0
- LDY #0
- @loop
- CLC
- LDA spriteram+3,x
- ADC speed,y
- STA spriteram+3,x
- STA $0203,x
- INY
- cpy #4
- BNE @skipreset
- LDY #0
- @skipreset
- INX
- INX
- INX
- INX
- CPX #0
- BNE @loop
- RTS
- playleft:
- LDX #0
- LDY #0
- @loop
- CLC
- LDA spriteram+3,x
- SBC speed,y
- STA spriteram+3,x
- STA $0203,x
- INY
- cpy #4
- BNE @skipreset
- LDY #0
- @skipreset
- INX
- INX
- INX
- INX
- CPX #0
- BNE @loop
- RTS
- ; Sprite direction subroutines end
- ;---------------------------------
- ;----------------------------------
- ; sprite animation subroutine start
- animatesprites:
- DEC spriteanimationcounter
- lda spriteanimationcounter
- CMP #$00
- BNE noanimationthiscycle
- ;increment SPRITE number here
- INC spritenumber
- LDA spritenumber
- CMP #4
- BCC NoResetSpr
- lda #0
- sta spritenumber
- NoResetSpr:
- LDA spriteanimationnumber
- STA spriteanimationcounter
- noanimationthiscycle:
- rts
- ; sprite animation subroutine end
- ;--------------------------------
- ;--------------------------------
- ; change sprite subroutine
- changesprites
- lda spritenumber
- ;------------------
- SprNum0:
- CMP #0
- BNE SprNum1
- ldx #0
- ldy #0
- -
- lda spritetiles0,y
- sta $201,x
- iny
- cpy #$0f
- BNE @skipreset
- LDY #0
- @skipreset
- inx
- inx
- inx
- inx
- bne -
- JMP SprChangeOver
- ;------------------
- SprNum1:
- CMP #1
- BNE SprNum2
- ldx #0
- ldy #0
- -
- lda spritetiles1,y
- sta $201,x
- iny
- cpy #$0f
- BNE @skipreset
- LDY #0
- @skipreset
- inx
- inx
- inx
- inx
- bne -
- JMP SprChangeOver
- ;------------------
- SprNum2:
- CMP #2
- BNE SprNum3
- ldx #0
- ldy #0
- -
- lda spritetiles2,y
- sta $201,x
- iny
- cpy #$0f
- BNE @skipreset
- LDY #0
- @skipreset
- inx
- inx
- inx
- inx
- bne -
- JMP SprChangeOver
- ;------------------
- SprNum3:
- CMP #3
- BNE SprChangeOver
- ldx #0
- ldy #0
- -
- lda spritetiles3,y
- sta $201,x
- iny
- cpy #$0f
- BNE @skipreset
- LDY #0
- @skipreset
- inx
- inx
- inx
- inx
- bne -
- JMP SprChangeOver
- SprChangeOver:
- RTS
- ;----data tables----
- loadspritedir:
- .word playup,playdown,playleft,playright
- loadspritetile:
- .word spritetiles0,spritetiles1,spritetiles2,spritetiles3
- palette:
- .db $0F,$f0,$24,$f0,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F,$0F ;
- .db $0F,$04,$14,$24,$0F,$14,$24,$34,$0F,$04,$14,$24,$0F,$14,$24,$34 ; palette 0
- offset_table:
- .db $e0,$e1,$e2,$e3,$e4,$e5,$e6,$e7,$e8,$e9,$ea,$eb,$ec,$ed,$ee,$ef
- .db $f0,$f1,$f2,$f3,$f4,$f5,$f6,$f7,$f8,$f9,$fa,$fb,$fc,$fd,$fe,$ff
- speed:
- .db $01,$02,$03,$04
- virtpos:
- .db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
- .db $1,$2,$3,$4,$5,$6,$7,$8,$A,$C,$E,$10,$12,$14,$16,$18
- .db $1A,$1C,$1E,$20,$22,$24,$26,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F,$30
- .db $30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30
- .db $30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30,$30
- .db $2F,$2E,$2D,$2C,$2B,$2A,$29,$28,$26,$24,$22,$20,$1E,$1C,$1A,$18
- .db $16,$14,$12,$10,$E,$C,$A,$8,$7,$6,$5,$4,$3,$2,$1,$0
- .db $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0
- sprites:
- ;vert tile attr horiz
- .db $08, $00, $20, $a4
- .db $08, $01, $20, $c9
- .db $08, $02, $20, $84
- .db $10, $03, $20, $88
- .db $10, $04, $20, $e5
- .db $18, $05, $20, $20
- .db $18, $06, $20, $31
- .db $20, $07, $20, $17
- .db $28, $08, $20, $6e
- .db $28, $09, $20, $89
- .db $30, $0a, $20, $6b
- .db $38, $0b, $20, $e1
- .db $38, $00, $20, $5a
- .db $38, $01, $20, $bd
- .db $40, $02, $20, $90
- .db $40, $03, $20, $bf
- .db $48, $04, $20, $53
- .db $48, $05, $20, $63
- .db $48, $06, $20, $9d
- .db $50, $07, $20, $e9
- .db $50, $08, $20, $f3
- .db $58, $09, $20, $13
- .db $60, $0a, $20, $53
- .db $60, $0b, $20, $88
- .db $68, $00, $20, $76
- .db $68, $01, $20, $bb
- .db $68, $02, $20, $f6
- .db $70, $03, $20, $dd
- .db $70, $04, $20, $df
- .db $78, $05, $20, $86
- .db $78, $06, $20, $1d
- .db $80, $07, $20, $e1
- .db $80, $08, $20, $ca
- .db $80, $09, $20, $99
- .db $88, $0a, $20, $c3
- .db $88, $0b, $20, $5e
- .db $90, $00, $20, $1f
- .db $98, $01, $20, $1e
- .db $98, $02, $20, $99
- .db $98, $03, $20, $e2
- .db $a0, $04, $20, $3d
- .db $a0, $05, $20, $a2
- .db $a8, $06, $20, $24
- .db $b0, $07, $20, $ec
- .db $b0, $08, $20, $09
- .db $b0, $09, $20, $16
- .db $b8, $0a, $20, $aa
- .db $b8, $0b, $20, $5b
- .db $c0, $00, $20, $54
- .db $c0, $01, $20, $fa
- .db $c0, $02, $20, $74
- .db $c8, $03, $20, $c9
- .db $c8, $04, $20, $0b
- .db $d0, $05, $20, $a9
- .db $d0, $06, $20, $37
- .db $d0, $07, $20, $e2
- .db $d8, $08, $20, $74
- .db $d8, $09, $20, $1d
- .db $d8, $0a, $20, $85
- .db $e0, $0b, $20, $d1
- .db $e0, $00, $20, $f4
- .db $e8, $01, $20, $da
- .db $e8, $02, $20, $31
- .db $e8, $03, $20, $12
- spritetiles0:
- .db $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0a,$0b,$0c,$0d,$0e,$0f
- spritetiles1:
- .db $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1a,$1b,$1c,$1d,$1e,$1f
- spritetiles2:
- .db $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f
- spritetiles3:
- .db $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f
- ;----include picture data----
- .ORG $C000
- .include "charmap.bin" ; Attach character map to ROM
- titlescreen:
- .incbin "titlescreen.nam"
- blank:
- .incbin "blank.nam"
- ;----vectors----
- .ORG $fffa
- .DW NMI
- .DW Reset
- .DW IRQ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement