home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
programs
/
emulaton
/
asm6503
/
examples
/
c64sprite
< prev
next >
Wrap
Text File
|
1998-08-25
|
4KB
|
136 lines
;Alain BROBECKER (aka baah/Arm's Tech), 07sep1997
;Sprites bouncing on screen
#name c64SpriteX
#type &064
#list
#base &801-2
;---- Constants ----------------------------------------------------------------
; &fb to &fe can be used as temp?
#set CountDown = &fb ; used as a timer
;---- C64 specific part... loading adress+BASIC stuff --------------------------
#rw &0801 ; Load adress (C64)
#rw BasicEnd,1997 ; Adress of next line + line number
#b &9e,&32,&30,&36,&32 ; Basic "SYS2062" instruction
#b 0 ; End of basic line
.BasicEnd
#b 0,0,0 ; End of basic program
;---- Assembly language ForEVER ------------------------------------------------
.start
ldx #7
.init_sprites
lda #sprite>>6 ; Sprite's adress
sta &7f8,x ; Save sprite adress for sprite x
txa
ora #&8
sta &d027,x ; Save sprite's color
dex
bpl init_sprites
lda #&ff
sta &d015 ; All sprites activated
sta &d017 ; Vsize*2
sta &d01d ; Hsize*2
lda #0
sta &d010 ; sprites' 9th bit of x_pos set to 0
lda #0
sta z,CountDown
.one_frame
ldy #&0 ; Video synchronisation
.vsync
cpy &d012
bne vsync
ldx #15
.one_sprite
lda z,CountDown
sta &400
and #&f
bne no_gravity
inc sprite_speed,x ; vy+=1 for gravity
.no_gravity
; Perform mvts+bounce on y pos
clc
lda sprite_pos,x ; akku=y
adc sprite_speed,x ; akku=y+vy
cmp #50 ; flags=y+vy-50
bcs yup_ok
sec
lda #0
sbc sprite_speed,x ; akku=-vy
sta sprite_speed,x ; vy=-vy
clc
adc sprite_pos,x ; akku=y+vy
.yup_ok
cmp #229 ; flags=y+vy-229
bcc ydown_ok
sec
lda #0
sbc sprite_speed,x ; akku=-vy
sta sprite_speed,x ; vy=-vy
clc
adc sprite_pos,x ; akku=y+vy
.ydown_ok
sta &d000,x
sta sprite_pos,x
; Do the same with x position
dex
clc
lda sprite_pos,x ; akku=x
adc sprite_speed,x ; akku=x+vx
cmp #24 ; flags=x+vx-24
bcs xleft_ok
sec
lda #0
sbc sprite_speed,x ; akku=-vx
sta sprite_speed,x ; vy=-vx
clc
adc sprite_pos,x ; akku=x+vx
.xleft_ok
cmp #255 ; flags=x+vx-200
bcc xright_ok
sec
lda #0
sbc sprite_speed,x ; akku=-vx
sta sprite_speed,x ; vx=-vx
clc
adc sprite_pos,x ; akku=x+vx
.xright_ok
sta &d000,x
sta sprite_pos,x
dex
bpl one_sprite
dec z,CountDown
bne one_frame
rts
;---- Datas --------------------------------------------------------------------
.sprite_pos
#b 80,80, 100,100, 120,120, 140,140, 160,160, 180,180, 200,200, 220,220
.sprite_speed
#b 2,0, 2,0, 3,0, 1,0, 4,0, 3,0, 1,0, 2,0
#align &3f,0 ; Sprite's adress must be a multiple of 64
.sprite
#b %00000000,%11111000,%00000000
#b %00000011,%11111110,%00000000
#b %00001111,%11111111,%10000000
#b %00011111,%11111111,%11000000
#b %00111111,%11110001,%11100000
#b %00111111,%11100000,%11100000
#b %01111011,%11000100,%01110000
#b %01110001,%11001110,%01110000
#b %11111011,%11000100,%01111000
#b %11111111,%11100000,%11111000
#b %11111111,%11110001,%11111000
#b %11111111,%11111111,%11111000
#b %11111111,%11111111,%11111000
#b %01111111,%11111111,%11110000
#b %01111100,%11111111,%11110000
#b %00111000,%01111111,%11100000
#b %00111000,%01111111,%11100000
#b %00011100,%11111111,%11000000
#b %00001111,%11111111,%10000000
#b %00000011,%11111110,%00000000
#b %00000000,%11111000,%00000000