Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vars.asm
- UGLOO_RAM = $0200
- FRAME1 = $0C
- FRAME2 = $18
- FRAME3 = $24
- FRAME4 = $30
- .rsset $0000
- sleeping .rs 1
- controller .rs 3
- chrPointer .rs 2
- frame .rs 1
- animation .rs 1
- direction .rs 1
- spritePointer .rs 2 ; 2 bytes for every 4x4 meta sprite
- gfxPointer .rs 2
- spritePointerIndex .rs 1
- sprites.asm
- UglooSprite:
- .db $01, $01, $02, $02, %00000000, %01000000, %00000000, %01000000
- .db $01, $01, $03, $04, %00000000, %01000000, %00000000, %00000000
- .db $01, $01, $04, $03, %00000000, %01000000, %01000000, %01000000
- main.asm
- .inesprg 2
- .ineschr 0
- .inesmap 0
- .inesmir 1
- .include "inc/vars.asm"
- .bank 0
- .org $8000
- ; VBlank
- VBlankWait:
- BIT $2002
- BPL VBlankWait
- RTS
- ; WaitFrame
- WaitFrame:
- INC sleeping
- .loop:
- LDA sleeping
- BNE .loop
- RTS
- ; ----------------------------------------
- ; Controller
- ReadController:
- LDA controller
- STA controller+1
- LDA #$01
- STA $4016
- LDA #$00
- STA $4016
- LDX #$08
- .loop:
- LDA $4016
- LSR A
- ROL controller
- DEX
- BNE .loop
- LDA controller+1
- EOR #%11111111
- AND controller
- STA controller+2
- RTS
- HandleInput:
- LDA controller+2
- AND #%00001111
- BEQ .return
- AND #%00000100
- BEQ .return
- JSR MoveDown
- .return:
- RTS
- ; ----------------------------------------
- ; Load CHR
- LoadCHRBank:
- LDA #LOW(SpriteData)
- STA chrPointer
- LDA #HIGH(SpriteData+1)
- STA chrPointer+1
- LDY #$00
- LDA $2002
- LDA [chrPointer], Y
- STA $2006
- INC chrPointer
- LDA [chrPointer], Y
- STA $2006
- INC chrPointer
- LDX #$00
- LDY #$00
- .loop:
- LDA [chrPointer], Y
- STA $2007
- INY
- CPY #$00
- BNE .loop
- INC chrPointer+1
- INX
- CPX #$10
- BNE .loop
- RTS
- ; ----------------------------------------
- Reset:
- SEI
- CLD
- LDX #$40
- STX $4017
- LDX #$FF
- TXS
- INX
- STX $2000
- STX $2001
- STX $4010
- BIT $2002
- JSR VBlankWait
- ClrMem:
- 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
- STA $0200, X
- INX
- BNE ClrMem
- BIT $2002
- JSR VBlankWait
- LDA $2002
- LDA #$3F
- STA $2006
- LDA #$10
- STA $2006
- LoadPalettes:
- LDA Palettes, X
- STA $2007
- INX
- CPX #$10
- BNE LoadPalettes
- LDA #$80
- STA UGLOO_RAM
- STA UGLOO_RAM+3
- LDA #LOW(UglooSprite)
- STA spritePointer
- LDA #HIGH(UglooSprite+1)
- STA spritePointer+1
- LDA #$00
- STA $2003
- LDA #$00
- STA spritePointerIndex
- JSR LoadCHRBank
- LDA #%10010000
- STA $2000
- Forever:
- JSR WaitFrame
- JSR ReadController
- JSR HandleInput
- JSR SpriteAnimation
- JSR SpriteFrameUpdate
- JSR UpdateUgloo
- JMP Forever
- Nmi:
- PHA
- TXA
- PHA
- TYA
- PHA
- LDA #$02
- STA $4014
- LDA #$00
- STA $2005
- STA $2005
- STA $2006
- STA $2006
- LDA #%00011110
- STA $2001
- LDA #$00
- STA sleeping
- PLA
- TAY
- PLA
- TAX
- PLA
- RTI
- Palettes:
- .db $0F, $C2, $08, $21, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F
- .bank 1
- .org $A000
- SpritesDown:
- .db $00, $08, $10
- MoveDown:
- LDA #$01
- STA direction
- LDA UGLOO_RAM
- CLC
- ADC #02
- STA UGLOO_RAM
- INC animation
- RTS
- UpdateUgloo:
- LDA UGLOO_RAM
- STA UGLOO_RAM+4
- CLC
- ADC #$08
- STA UGLOO_RAM+8
- STA UGLOO_RAM+12
- LDA UGLOO_RAM+3
- STA UGLOO_RAM+11
- CLC
- ADC #$08
- STA UGLOO_RAM+7
- STA UGLOO_RAM+15
- RTS
- SpriteAnimation:
- LDA animation
- CMP #FRAME1
- BEQ .anim1
- CMP #FRAME2
- BEQ .anim2
- CMP #FRAME3
- BEQ .anim1
- CMP #FRAME4
- BEQ .anim3
- JMP .done
- .anim1:
- LDA #$00
- STA frame
- JMP .done
- .anim2:
- LDA #$01
- STA frame
- JMP .done
- .anim3:
- LDA #$02
- STA frame
- JMP .done
- .done:
- LDA animation
- CMP #FRAME4
- BNE .return
- SEC
- SBC #FRAME4
- STA animation
- .return:
- RTS
- SpriteFrameUpdate:
- LDA direction
- BEQ .up
- CMP #$01
- BEQ .down
- CMP #$02
- BEQ .left
- JMP .right
- .up:
- LDA frame
- TAX
- LDA SpritesDown, X
- TAY
- JSR UpdateCHRRam
- .down
- LDA frame
- TAX
- LDA SpritesDown, X
- TAY
- JSR UpdateCHRRam
- .left
- LDA frame
- TAX
- LDA SpritesDown, X
- TAY
- JSR UpdateCHRRam
- .right
- LDA frame
- TAX
- LDA SpritesDown, X
- TAY
- JSR UpdateCHRRam
- UpdateCHRRam:
- LDX spritePointerIndex
- LDA spritePointer, X
- STA gfxPointer
- INX
- LDA spritePointer, X
- STA gfxPointer+1
- LDA [gfxPointer], Y
- STA UGLOO_RAM+1, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+5, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+9, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+13, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+2, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+6, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+10, X
- INY
- LDA [gfxPointer], Y
- STA UGLOO_RAM+14, X
- RTS
- .bank 2
- .org $C000
- .include "inc/sprites.asm"
- .bank 3
- .org $E000
- SpriteData:
- .db $00, $00
- .incbin "inc/crapMeta.chr"
- .org $FFFA
- .dw Nmi
- .dw Reset
- .dw 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement