2022-02-16 20:50:48 +00:00
|
|
|
|
|
|
|
//#resource "vcs-ca65.h"
|
|
|
|
|
|
|
|
import "vcslib.ecs"
|
|
|
|
|
|
|
|
component Bitmap
|
|
|
|
bitmapdata: array of 0..255 baseoffset 31
|
|
|
|
height: 0..255
|
|
|
|
end
|
|
|
|
|
2022-02-28 01:46:26 +00:00
|
|
|
// TODO: remove?
|
2022-02-16 20:50:48 +00:00
|
|
|
component HasBitmap
|
|
|
|
end
|
|
|
|
|
|
|
|
component Colormap
|
|
|
|
colormapdata: array of 0..255 baseoffset 31
|
|
|
|
end
|
|
|
|
|
|
|
|
component HasColormap
|
|
|
|
colormap: [Colormap]
|
|
|
|
end
|
|
|
|
|
|
|
|
component Sprite
|
2022-02-28 01:46:26 +00:00
|
|
|
bitmap: [Bitmap]
|
2022-02-16 20:50:48 +00:00
|
|
|
plyrflags: 0..63
|
|
|
|
end
|
|
|
|
|
|
|
|
component HasXpos
|
|
|
|
xpos: 0..255
|
|
|
|
end
|
|
|
|
|
|
|
|
component HasYpos
|
|
|
|
ypos: 0..255
|
|
|
|
end
|
|
|
|
|
|
|
|
component Missile
|
2022-02-28 01:46:26 +00:00
|
|
|
index: 2..3
|
2022-02-16 20:50:48 +00:00
|
|
|
end
|
|
|
|
|
2022-02-28 01:46:26 +00:00
|
|
|
component SpriteSlot
|
|
|
|
sprite: [Sprite] // TODO: HasBitmap?
|
2022-02-16 20:50:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
system JoyFaceDirection
|
|
|
|
on joyleft do with [Sprite]
|
|
|
|
---
|
|
|
|
lda {{<plyrflags}}
|
|
|
|
ora #$08
|
|
|
|
sta {{<plyrflags}}
|
|
|
|
---
|
|
|
|
on joyright do with [Sprite]
|
|
|
|
---
|
|
|
|
lda {{<plyrflags}}
|
|
|
|
and #$f7
|
|
|
|
sta {{<plyrflags}}
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|
|
|
|
system MoveJoyX
|
|
|
|
on joyleft do with [HasXpos]
|
|
|
|
---
|
|
|
|
lda {{<xpos}}
|
|
|
|
sec
|
2022-02-28 01:46:26 +00:00
|
|
|
sbc #1
|
2022-02-16 20:50:48 +00:00
|
|
|
bcc @nomove
|
|
|
|
sta {{<xpos}}
|
|
|
|
@nomove:
|
|
|
|
---
|
|
|
|
on joyright do with [HasXpos]
|
|
|
|
---
|
|
|
|
lda {{<xpos}}
|
|
|
|
clc
|
|
|
|
adc #1
|
2022-02-28 01:46:26 +00:00
|
|
|
cmp #150
|
2022-02-16 20:50:48 +00:00
|
|
|
bcs @nomove
|
|
|
|
sta {{<xpos}}
|
|
|
|
@nomove:
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|
|
|
|
system MoveJoyY
|
|
|
|
on joyup do with [HasYpos]
|
|
|
|
---
|
|
|
|
lda {{<ypos}}
|
|
|
|
sec
|
|
|
|
sbc #1
|
|
|
|
bcc @nomove
|
|
|
|
sta {{<ypos}}
|
|
|
|
@nomove:
|
|
|
|
---
|
|
|
|
on joydown do with [HasYpos]
|
|
|
|
---
|
|
|
|
lda {{<ypos}}
|
|
|
|
clc
|
|
|
|
adc #1
|
|
|
|
cmp #220
|
|
|
|
bcs @nomove
|
|
|
|
sta {{<ypos}}
|
|
|
|
@nomove:
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|
2022-02-28 01:46:26 +00:00
|
|
|
system SetXPos
|
|
|
|
on preframe do join [SpriteSlot] with [Sprite]
|
|
|
|
limit 2
|
|
|
|
---
|
|
|
|
lda {{<xpos}}
|
|
|
|
{{!SetHorizPos}}
|
|
|
|
---
|
|
|
|
on preframe do foreach [Missile,HasXpos]
|
|
|
|
---
|
|
|
|
lda {{<xpos}}
|
|
|
|
ldy {{<index}}
|
|
|
|
{{!SetHorizPos}}
|
|
|
|
---
|
|
|
|
on prekernel do once
|
|
|
|
---
|
|
|
|
sta WSYNC
|
|
|
|
sta HMOVE
|
|
|
|
SLEEPR 24
|
|
|
|
sta HMCLR
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|
2022-02-16 20:50:48 +00:00
|
|
|
system SpriteShuffler
|
|
|
|
locals 2
|
|
|
|
on postframe do select [SpriteSlot]
|
|
|
|
---
|
|
|
|
; load two sprite slots at left side of array
|
|
|
|
lda {{<SpriteSlot:sprite}}
|
|
|
|
sta {{$0}}
|
|
|
|
lda {{<SpriteSlot:sprite}}+1
|
|
|
|
sta {{$1}}
|
|
|
|
; move two slots to the left
|
|
|
|
ldx #0
|
|
|
|
@loop:
|
|
|
|
lda {{<SpriteSlot:sprite}}+2,x
|
|
|
|
sta {{<SpriteSlot:sprite}},x
|
|
|
|
inx
|
|
|
|
cpx #{{%ecount}}-2
|
|
|
|
bne @loop
|
|
|
|
; store two sprite slots at right side of array
|
|
|
|
lda {{$0}}
|
|
|
|
sta {{<SpriteSlot:sprite}}+{{%ecount}}-2
|
|
|
|
lda {{$1}}
|
|
|
|
sta {{<SpriteSlot:sprite}}+{{%ecount}}-1
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|
|
|
|
system SpriteHider
|
|
|
|
locals 1
|
|
|
|
on postframe do select [SpriteSlot]
|
|
|
|
---
|
|
|
|
lda #{{%efullcount}}-1
|
|
|
|
sta {{$0}}
|
|
|
|
---
|
|
|
|
on postframe do
|
|
|
|
join [SpriteSlot]
|
|
|
|
with [Sprite,HasYpos]
|
|
|
|
limit 2
|
|
|
|
---
|
|
|
|
lda {{<ypos}}
|
|
|
|
cmp #192
|
|
|
|
bcc @skip
|
|
|
|
; swap this sprite slot with slot at end of array
|
|
|
|
lda {{<SpriteSlot:sprite}},y
|
|
|
|
pha
|
|
|
|
ldx {{$0}} ; clobbers X, but no longer used
|
|
|
|
lda {{<SpriteSlot:sprite}},x
|
|
|
|
sta {{<SpriteSlot:sprite}},y
|
|
|
|
pla
|
|
|
|
sta {{<SpriteSlot:sprite}},x
|
|
|
|
dec {{$0}}
|
|
|
|
@skip:
|
|
|
|
---
|
|
|
|
end
|
|
|
|
|