Jump to content
  • entries
  • comments
  • views

A C64 game - Step 3

Sign in to follow this  


Quite similar to step 2 this time we set up sprites. Note that I used another selfmade tool (similar to SpritePad). The file J.SPR contains the sprites and is included into the source as binary. The sprites are located "under" the I/O ROM at $D000 onwards.


And another note: Since I'm lazy I built the sprite copy loop to always copy packages of 4 sprites (1 sprite comes as 63 + 1 byte, so 4 make nice 256 byte packages).

The current step should display the known charset garbage and "HELLO" as before, but also show an elegantly handicrafted sprite.

Right below the charset copy routine we add the copy call.


          ;take source address from SPRITES
          lda #<SPRITES
          sta ZEROPAGE_POINTER_1
          lda #>SPRITES
          sta ZEROPAGE_POINTER_1 + 1
          jsr CopySprites


The sprite copy routine is quite similar to the charset copy but a tad shorter due to the 256 byte packaging:

          ;copies sprites from ZEROPAGE_POINTER_1 to ZEROPAGE_POINTER_2
          ; sprites are copied in numbers of four
!zone CopySprites
          ldy #$00
          ldx #$00
          lda #00
          sta ZEROPAGE_POINTER_2
          lda #$d0
          sta ZEROPAGE_POINTER_2 + 1
          ;4 sprites per loop
          lda (ZEROPAGE_POINTER_1),y
          sta (ZEROPAGE_POINTER_2),y
          bne .SpriteLoop
          inc ZEROPAGE_POINTER_1 + 1
          inc ZEROPAGE_POINTER_2 + 1
          cpx #NUMBER_OF_SPRITES_DIV_4
          bne .SpriteLoop


In front of GameLoop we put the sprite display code. The sprite is positioned at coordinates 100,100, the sprite pointer set to the correct image and the sprite is enabled.

          ;set sprite 1 pos
          lda #100
          sta VIC_SPRITE_X_POS
          sta VIC_SPRITE_Y_POS
          ;set sprite image
          lda #SPRITE_PLAYER
          ;enable sprite 1
          lda #1
          sta VIC_SPRITE_ENABLE



Previous Step 2 Next Step 4

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!