pouët.net

ABBATONE by Abaddon [web]

;ABBATONE by Abaddon
;ZX Spectrum 256b intro for CafeParty2019

;48k code: TomCat & G.o.D.
;AY music: ern0

ORG $8000

note1: DW 1920/8;2034/8
note2: DW 2562/8
note3: DW 3421/8
noise: DB 31
mixer: DB 00001000B
vol1: DB 15+16
vol2: DB 15+16
vol3: DB 15+16
durf: DB 0
durc: DB 7
wave: DB 8

sqr:
 EXX
 LD H,A
 LD L,0
 LD D,L
 LD E,A
 LD B,8
sqr1:
 ADD HL,HL
 JR NC,sqr2
 ADD HL,DE
sqr2:
 DJNZ sqr1
 LD A,H
 EXX
 INC C
RET

offs:
 DB 16
 DB 0
 DB 64+16
 DB 192

attr:
 DB 00+16+03
 DB 64+16+05
 DB 64+08+03
;DB 64+00+06

start:
 LD BC,256*32
 DI
 LD SP,unroll+70
 LD HL,nextframe
 PUSH HL
 LD HL,$E280
 PUSH HL
 LD DE,256*(nextline&255)+$EA
 PUSH DE
 LD DE,$A0ED
copy:
 PUSH DE
 DJNZ copy 
 LD SP,HL
 EX DE,HL

 LD L,B
loopx1:
 LD D,1
loopx2:
 LD A,C
 SUB E
 JR NC,absx
 CPL
 OUT ($FE),A
absx:
 ADD A,B
 SLA (HL)
 BIT 3,A
 JR Z,skip1
 SET 0,(HL)
skip1:
 CALL sqr
 SLA D
 BIT 3,A
 JR Z,skip2
 SET 0,D
skip2:
 JR NC,loopx2
 LD A,(HL)
 XOR D
 SET 6,L
 LD (HL),D
 SET 7,L
 LD (HL),A
 INC L
 RES 6,L
 RES 7,L
 JR NZ,loopx1
 INC H
 INC B
 LD A,B
 CP 32
 JR NZ,loopx1

loopy:
 LD A,C
 SUB 96
 JR NC,absy
 CPL
absy:
 LD (HL),A
 CALL sqr
 INC L
 LD (HL),A
 DEC L
 INC H
 LD A,H
 AND 7
 JR NZ,loopy
 LD A,L
 ADD A,B
 LD L,A
 JR Z,loopy
 LD A,H
 SUB 8
 LD H,A
 CP 11011000B
 JR NZ,loopy

nextpart:
 LD A,D
 AND 7+offs&255
 LD D,A

 LD L,D
 RES 2,L
 LD A,(HL)
 SET 2,L
 PUSH HL

 LD L,(offsetx+1)&255
 LD (HL),0
 BIT 2,D
 JR NZ,noxor
 INC (HL)
 XOR 16
noxor:
 LD L,(part+1)&255
 LD (HL),A
 INC D

 EXX
 LD B,3
 POP HL
 PUSH DE
 LDI
 POP HL
 LDIR

nextframe:
 EXX
 LD HL,timer+1
 LD A,(HL)
 INC (HL)
 JR Z,nextpart
 LD L,(part+1)&255
 CP 256-15
 JR C,skip
 INC (HL)
 LD L,mixer&255
 LD A,(HL)
 XOR 00110000B
 LD (HL),A
 SUB A
skip:
 AND 63
 JR NZ,nosound
 LD L,wave&255
nextnote:
 LD BC,$FFFD
 OUT (C),L
 LD B,$BF
 OUTD
 JR NC,nextnote
 INC HL
 LD A,(HL)
 XOR $0E
 LD (HL),A
nosound:

 EXX
 LD DE,$4000
 LD B,32*192/256
nextline:
;EX (SP),HL   ;19TS
;EX (SP),HL   ;19TS
 ADD HL,HL    ;11TS
 ADD HL,HL    ;11TS
;LD A,(HL)    ;7TS
;LD A,(HL)    ;7TS
 INC HL       ;6TS
;INC HL       ;6TS
;NOP          ;4TS
;NOP          ;4TS
offsetx:
 LD HL,$8000
 ADD HL,DE
timer:
 LD A,254
 ADD A,(HL)
 AND 31
 ADD A,$A0
 LD H,A
part:
 LD L,0
unroll: