1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-25 03:34:05 +00:00
8bitworkshop/test/ecs/titles.ecs
2022-02-16 21:46:50 -06:00

132 lines
3.5 KiB
Plaintext

//#resource "vcs-ca65.h"
import "vcslib.ecs"
component Bitmap48
bitmap0: array of 0..0xff
bitmap1: array of 0..0xff
bitmap2: array of 0..0xff
bitmap3: array of 0..0xff
bitmap4: array of 0..0xff
bitmap5: array of 0..0xff
height: 0..255
end
system Kernel48Pixel
locals 2
on kernelsetup do if [Bitmap48] ---
lda {{<height}}
sta {{$0}} ; scanline counter
lda #$22
sta COLUP0 ; show how players alternate
lda #$12
sta COLUP1 ; by having different colors
lda #3
sta NUSIZ0
sta NUSIZ1 ; both players have 3 copies
sta WSYNC
SLEEPH 34
sta RESP0 ; position 1st player
sta RESP1 ; ...and 2nd player
lda #$10
sta HMP1 ; 1 pixel to the left
sta WSYNC
sta HMOVE ; apply HMOVE
SLEEPH 24 ; sleep 24 cycles
sta HMCLR ; clear HMOVE registers
lda #1
sta VDELP0 ; we need the VDEL registers
sta VDELP1 ; so we can do our 4-store trick
---
/* already exists on StaticKernel
on kernelsetup do if [BGColor] ---
lda {{<bgcolor}}
sta COLUBK
---
*/
on kernelsetup do if [PFColor] ---
lda {{<pfcolor}}
sta COLUP0
sta COLUP1
---
on kerneldraw do if [Bitmap48] ---
txa
pha
@Loop:
ldy {{$0}} ; counts backwards
sta WSYNC ; sync to next scanline
lda {{data bitmap0}},y ; load B0 (1st sprite byte)
sta GRP0 ; B0 -> [GRP0]
lda {{data bitmap1}},y ; load B1 -> A
sta GRP1 ; B1 -> [GRP1], B0 -> GRP0
lda {{data bitmap2}},y ; load B2 -> A
sta GRP0 ; B2 -> [GRP0], B1 -> GRP1
lda {{data bitmap5}},y ; load B5 -> A
sta {{$1}} ; B5 -> temp
ldx {{data bitmap4}},y ; load B4 -> X
lda {{data bitmap3}},y ; load B3 -> A
ldy {{$1}} ; load B5 -> Y
sta GRP1 ; B3 -> [GRP1]; B2 -> GRP0
stx GRP0 ; B4 -> [GRP0]; B3 -> GRP1
sty GRP1 ; B5 -> [GRP1]; B4 -> GRP0
sta GRP0 ; ?? -> [GRP0]; B5 -> GRP1
dec {{$0}} ; go to next line
bpl @Loop ; repeat until < 0
pla
tax
---
end
demo Main
//using FrameLoop, StaticKernel, Kernel48Pixel
using FrameLoop, Kernel48Pixel, StaticKernel
// TODO
entity [KernelSection, BGColor]
const lines = 10
const bgcolor = $a0
end
entity [KernelSection, BGColor]
const lines = 10
const bgcolor = $a2
end
entity [KernelSection, BGColor, PFColor, Bitmap48]
const lines = 2
const bgcolor = 0xa4
const pfcolor = 0xfc
decode vcs_bitmap48 ---
x.............................................xx
xx.........................................xxx.x
xxxx....................................xxx....x
xx..xxxx..............................xx.......x
xx......xx...........................x.........x
xx...x....x............xx............x.........x
xx...x....x...........x..x.........xx..........x
xx...x..x..x....x......xx.....x...x............x
xx...xxxx...x...xxx...x..x..xxx..x.............x
xx...x..x..x......x....xx...x.....x............x
xx...x....x...........x..x.........xx..........x
xx......xx.............xx............x.........x
xx..xxxx..............................xx.......x
xxxx....................................xxxxxxxx
................................................
---
end
entity [KernelSection, BGColor]
const lines = 10
const bgcolor = $a2
end
entity [KernelSection, BGColor]
const lines = 10
const bgcolor = $a0
end
end