nolist
org &2000
start:
ld a,1:call &bc0e
call getfonts
call blackout
call cls
ld de,palbw:ld a,4:call changepal
call gensine0
call testsine
again:
call vsyncsafe:call scrollcopy:ld e,0:call writefont
call vsyncsafe:call scrollcopy:ld e,8:call writefont
ld a,(scrpointer):inc a:ld (scrpointer),a
jr again
stp:
jr stp
testsine:
ld hl,&c000
ld de,sine0
exx:ld d,25:exx
epi25:
ld bc,2048
exx:ld e,8:exx
epi8:
push hl:push bc
ld a,(de):inc e
srl a:srl a:ld c,a:ld b,0:add hl,bc
ld (hl),a
pop bc:pop hl:add hl,bc
exx:dec e:exx
jr nz,epi8
ld bc,-16384+80:add hl,bc
exx:dec d:exx
jr nz,epi25
ret
gensine0:
exx:ld de,sine0:exx
ld hl,127*256:ld de,-4*256
epi256:
add hl,de:ex de,hl:add hl,bc:ex de,hl
ld a,h
push af
cp 127
jr nc,nodown
ld bc,32
ld a,(change):or a
jr nz,nochang1
ld de,-4*256
nochang1:
ld a,1:ld (change),a
jr noup
nodown:
ld bc,-32
ld a,(change):dec a
jr nz,nochang2
ld de,4*256
nochang2:
ld a,0:ld (change),a
noup:
pop af
exx:ld (de),a:inc e:exx
jr nz,epi256
ret
change:
db 0
cls:
ld hl,&C000:ld de,&C001:ld bc,16383:ld (hl),0:ldir
ret
scrollcopy:
ld hl,&C000+1601:ld (am1+1),hl:dec l:ld (am2+1),hl
exx:ld d,8:ld b,d:exx
times8:
am1:
ld hl,&C000+1601
am2:
ld de,&C000+1600:ld bc,79:ldir
exx:ld a,(am1+2):add b:ld (am1+2),a:ld (am2+2),a:dec d:exx
jr nz,times8
ret
writefont:
ld a,(scrpointer)
ld h,&22:ld l,a
ld a,(hl):sub 32:ld b,a
srl a:srl a:srl a:srl a:add &24:ld d,a
ld a,b:add a:add a:add a:add a:add e:ld e,a
ld bc,2048
ld hl,&C000+1600+79
exx:ld d,8:exx
loop8:
ld a,(de):inc de
ld (hl),a:add hl,bc
exx:dec d:exx
jr nz,loop8
ret
scrpointer:
db 0
; ===== Data =====
palbw:
db 0,26,13,3
; === Demo Subs ===
getfonts:
ld a,32
printfonts:
call 47962
push af
pop af
inc a
cp 127
jr nz, printfonts
di:call disableints
ld hl,&C000
ld de,fonts
exx:ld d,0:exx
epi95:
ld bc,2048
exx:ld e,8:exx
fepi8:
ld a,(hl):add hl,bc
ld (de),a:inc de
exx:dec e:exx
jp nz,fepi8
ld bc,-16384+65536+1:add hl,bc
exx:dec d:exx
jr nz,epi95
ret
; ==== General Subs ====
delay:
call vsyncsafe
dec d
jr nz,delay
ret
; ---- Putting all colors to black ----
blackout:
ld bc,&7f00
nextblackout:
out (c),c:ld a,&54:out (c),a:inc c
ld a,c:cp 17
jr nz,nextblackout
ret
vsyncsafe:
push af:push bc
ld b,&f5
vsync1:
in a,(c)
rra
jp nc,vsync1
vsync2:
in a,(c)
rra
jp c,vsync2
pop bc:pop af
ret
disableints:
di:LD HL,&C9FB:LD(&38),HL
ret
; Pallete changing subroutine
; ---------------------------
; DE = Paltable
; A = number of colors used
changepal:
ld (noc+1),a
ld bc,&7f00
palloop:
push de:push bc
out (c),c
ld a,(de):ld d,0:ld e,a
ld hl,palcodes:add hl,de
ld c,(hl):out (c),c
pop bc:pop de
inc bc:inc de
ld a,c
noc:
cp 16
jr nz,palloop
ret
;Hardware colour pallete precs
; ---------------------------
palcodes:
db &54,&44,&55,&5c
db &58,&5d,&4c,&45
db &4d,&56,&46,&57
db &5e,&40,&5f,&4e
db &47,&4f,&52,&42
db &53,&5a,&59,&5b
db &4a,&43,&4b
list:
tend:
nolist
org &2200
scrtext:
db " Optimus shamelessly presents his first 1kb intro for the CPC."
db "I know this might suck, but I just wanted to support the Forever CPC compos "
db "and there is neither time nor ideas (and size :) left."
db "1kb coding seems interesting for the CPC! "
list
zzee:
nolist
org &2400
fonts:
org &3000
sine0: