Snippets

ScorpionIlluminati Sprite List Code

Created by ScorpionIlluminati last modified
1
2
3
4
5
6
7
8
     ; add the selection table to the sprite list
      move.w #selectionarrow_start_position_y, d0                              ; Y coord (+ 128)
      move.b SelectionArrowDimensionBits, d1                                   ; Width (bits 0-1) and height (bits 2-3) in tiles
      move.b 0x00, d2                                                          ; H/V flipping (bits 3/4), palette index (bits 5-6), priority (bit 7)
      move.b SelectionArrowTileID, d3                                          ; Index of first tile
      move.w #selectionarrow_start_position_x, d4                              ; x coord (+ 128)
      lea (spritelist_table), a0                                               ; load address of sprite list table into a0
      bsr AddSprite    
; *************************************************************
; AddSprite
; Adds a sprite to the sprite table and increments counter
; d0 - sprites y position
; d1 - width and height tile bits
; d2 - special (flipping, palette index, priority)
; d3 - tile id
; d4 - sprites x position
; a0 - sprite table
; *************************************************************
AddSprite:
    move.b (sprite_count), d5                                                  ; sprint count in d5
    move.b d5, d6                                                              ; d6 is used to calculate the sprite table offset
    cmp.b #80, d5                                                              ; are there too many sprites in the table already?
    blt SpriteLimitNotReached                                                  ; if not branch
    rts                                                                        ; return
SpriteLimitNotReached:
    lsl.w #$03, d6                                                             ; calculate sprite table offset (sprite count * sprite size)
    add.w d6, a0                                                               ; increment address by offset
    move.w d0, (a0)+                                                           ; move sprites y position into table
    move.b d1, (a0)+                                                           ; move sprites demensions into table
    lsl.w #8, d2                                                               ; move  priority, palette and flips to upper bits
    or.w d2, d3                                                                ; combine with tile id
    move.w d2, (a0)+                                                           ; save sprites special bits and tile id in table
    addq.l #1, d5                                                              ; increment d5(sprite_count) by 1
    move.b d5, (a0)+                                                           ; index of next sprite is d5(sprite_count +1) 
;    move.b d3, (a0)+                                                           ; save sprites tile id in table
    move.w d4, (a0)+                                                           ; save sprites x position in table
    addq #1, (sprite_count)                                                    ; increment sprite counter by 1
    rts

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.