org #8000
;nolist
NBDOT EQU 64
TABMASK EQU #0000
TABDOT EQU #A000
TABCOS256 EQU #9400
TABCOS512 EQU #9500
TABSIN256 EQU #9700
di
ld hl,#C9FB
ld (#38),hl
ld sp,#1000
ld bc,#7FC6 ; ZIK in #C6
call ConnectRam ; instead of using OUT (C),C to connect the RAM, i call this little function to save RAM state
; cause shitty extensions (even post-ASIC) do not known if ASIC is enable or not and it may
; cause memory writing conflicts
ld de,#49A8
call #4000
ld bc,#7FC0
call ConnectRam
ld bc,#BC00+12
out (c),c
ld a,#30
inc b
out (c),a
inc c
dec b
out (c),c
inc b
xor a
out (c),a ; screen in #C000
; hardware sprites loaded in C4
; hardware sprite proportionnal font in C5
call UnlockAsic
call AsicOn
ld hl,Asicolors
ld de,#6400
ld bc,8
ldir
call AsicOff
ld l,#20
ld (hl),0
inc l
ld (hl),0
jp razmemory
; background colors from black to white with two greys
Asicolors: defw #0000,#3333,#9999,#FFFF
;--- PRECA FACTO
;
; automodification of screen adress computation routine
; screen is divided in 2 sections and 4 sub-sections
; First we display the lower-right star, then the lower left, reusing some datas
; Then almost the same compute for upper screen
preca_screenadr_facto
; fill 1/2 partie basse
ld hl,#4400+32
ld (preca_startadress+1),hl
ld a,#30
ld (preca_tabadrput+2),a
ld hl,#800
ld (precageneric_addoffset+1),hl
ld a,#80
ld (precageneric_cp+1),a
ld hl,64-#4000
ld (precageneric_reblock+1),hl
call preca_screenadr_generic
; fill 3/4 partie haute
ld hl,#7C00+32-64
ld (preca_startadress+1),hl
ld a,#36
ld (preca_tabadrput+2),a
ld hl,-#800
ld (precageneric_addoffset+1),hl
ld a,#30
ld (precageneric_cp+1),a
ld hl,#4000-64
ld (precageneric_reblock+1),hl
call preca_screenadr_generic
; we fill the array of screen adress for all cases where stars are out of the screen
; then the stars will be ploted to #0000
ld b,128
ld l,128
xor a
ld d,#30
preca_scr1_fill:
ld h,d
repeat 12
ld (hl),a
inc h
rend
inc l
djnz preca_scr1_fill
; we do not want to plot pixels at the very center of the screen!
; you may comment this code except the final RET to see the difference
xor a
ld b,12
ld hl,#3000
precafactorazcenter
ld (hl),a
inc h
djnz precafactorazcenter
ret
;
; to display stars as fast as possible, here are the structure for 2 sub-sections
;
; An array of 256 byte with upper 8 bits of screen adress related to the Y value
; An array of 256 byte with lower 8 bits of screen adress related to the Y value
; An array of 256 byte with the value to put related to the X value
; An array of 256 byte with the X byte offset to add to the screen adress
; followed by
; An array of 256 byte with the X offset to translate to the left screen part
; An array of 256 byte with the value to put related to the X value
;
;
preca_screenadr_generic
ld lx,0
ld b,128
preca_startadress: ld de,#4400+32
preca_scr1:
preca_tabadrput: ld hx,#30
ld (ix+0),e
inc hx
ld (ix+0),d
inc hx
pix1: ld a,#88
ld (ix+0),a
inc hx
srl a
cp 8 ; less significant bit disapear
jr nz,pix1next
ld a,#88
pix1next:ld (pix1+1),a ; pix is 128/64/32/16 then loop, this is mode 1 pixel values
ld a,128
sub b
srl a
srl a
ld (ix+0),a
; part2
inc hx
add a
inc a
ld (ix+0),a
inc hx
pix1b: ld a,#11
ld (ix+0),a
inc hx
add a
cp #10
jr nz,pix1bnext
ld a,#11
pix1bnext:ld (pix1b+1),a ; pix is 16/32/64/128 then loop, this is mode 1 pixel values
inc lx
precageneric_addoffset: ld hl,#800
add hl,de ; block suivant
ld a,h
and #F0
precageneric_cp: cp #80
jr nz,preca_scr1_nextblock
precageneric_reblock: ld de,64-#4000
add hl,de ; ligne suivante du premier block
preca_scr1_nextblock:
ex hl,de
; de=adresse ecran en cours
djnz preca_scr1
ret
razmemory:
ld hl,#A000
ld de,#A001
ld bc,#5FFF
ld (hl),l
ldir
ld hl,#4000
ld de,#4001
ld bc,#3FFF
ld (hl),l
ldir
call preca_screenadr_facto
call crtc_init_cubic_screen
;----------------- MAIN LOOP
dots_reloop:
ld bc,#7FC0
call ConnectRam
ld hl,#BE00 ; read de #BE a #C0
ld (dots_clear_readbuffer+1),hl
call dots_clear ; clear previous dots in #4000
call genestarentry
call dots_move
ld hl,#C000 ; write de #BE a #C0
ld (dots_clear_writebuffer+1),hl
call dots_put
call vbl
call hardware_sprite
ld bc,#BC00+12
out (c),c
ld a,#10
inc b
out (c),a ; CRTC now reads new dots en #4000
ld bc,#7FC3
call ConnectRam
ld hl,#BC00 ; read de #BC a #BE
ld (dots_clear_readbuffer+1),hl
call dots_clear
call genestarentry
call dots_move
ld hl,#BE00 ; write de #BC a #BE
ld (dots_clear_writebuffer+1),hl
call dots_put
call vbl
call hardware_sprite
ld bc,#BC00+12
out (c),c
ld a,#30
inc b
out (c),a ; CRTC now reads new dots in #C000
jr dots_reloop
;------------------ END OF MAIN LOOP
;
; The following array is my scheduler for the all intro
; Each function MUST manage is own sequence then when the
; function finish his job, she gives control to the next
; sequence.
; For my tests there was a loop which is unused in the
; final release.
;
hardware_sprite_sequence:
defw disablesprite
defw getlogo
defw enablesprite
defw setlogocolor
defw movelogo
defw fadelogo
defw disablesprite
defw razsprite
defw setscrollcolor
defw movescroll
defw disablesprite
defw gettorus
defw enablesprite
defw settoruscolor
defw movetorus
defw disablesprite
defw razsprite
defw setscrollcolor
defw movescroll
defw disablesprite
defw getcube
defw enablesprite
defw setcubecolor
defw movecube
defw disablesprite
defw razsprite
defw setscrollcolor
defw movescroll
defw disablesprite
defw getlogo
defw enablesprite
defw setlogocolor
defw movelogo
defw stopstars
defw thankyou
hardware_sprite_sequence_loop:
defw 0
hardware_sprite:ld hl,hardware_sprite_sequence
ld e,(hl)
inc hl
ld d,(hl)
ld a,e
or d
or a
jr nz,hardware_sprite_jump
ld hl,hardware_sprite_sequence_loop
ld (hardware_sprite+1),hl
jr hardware_sprite
hardware_sprite_jump
push de
ret
hardware_sprite_next:ret
fadelogo
ld a,9
dec a
ld (fadelogo+1),a
jr z,fadeend
ld a,1
fadetic: sub 1
ld (fadetic+1),a
ret z
call AsicOn
ld hl,#6422
ld b,30
fadeloop
ld a,(hl)
srl a
and #77
ld (hl),a
inc l
djnz fadeloop
call AsicOff
ret
fadeend
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
stopstars
; disable generation
ld a,#C9
ld (genestar),a
stoptempo: ld a,200
dec a
ld (stoptempo+1),a
ret nz
; disable dots display
ld a,#C9
ld (dots_move),a
ld (dots_put),a
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;
; Unlimited loop
;
thankyou
call vbl
ld bc,#BC00+12
out (c),c
ld a,#10
inc b
out (c),a ; screen in #4000
ld bc,#7FC0
call ConnectRam
; Display a small THANK YOU below the logo
ld h,#30
ld l,32 ; 32 pix sous le centre
ld e,(hl)
inc h
ld d,(hl) ; de=adresse ecran debut de ligne
ld hl,-9
add hl,de
ex hl,de
ld hl,thankyoudata
ld b,7
thankyoucopy
push bc
ld bc,18
ldir
ex hl,de
ld bc,#800-18
add hl,bc
ex hl,de
pop bc
djnz thankyoucopy
;--------- final loop
thankyouloop
call vbl
ld hl,0
ld a,8
call vumetre
add a
add a
add a
add a
ld l,a
ld a,9
call vumetre
or l
ld l,a
ld a,10
call vumetre
ld h,a
call Asicon
ld (#6406),hl
call Asicoff
jr thankyouloop
;
; Get the volume value for any AUDIO channel. Returns value from 0 to 15
;
; A=8,9 ou 10
vumetre
ld b,#F4
out (c),a
ld bc,#F6C0
out (c),c
ld bc,#F600
out (c),c
ld bc,#F792
out (c),c
ld bc,#F640
out (c),c
ld b,#F4
in a,(c)
ld bc,#F782
out (c),c
; retour dans A
ret
;
; i do not comment those one!
;
disablesprite
call AsicOn
ld ix,#6000
ld de,8
ld b,16
ld c,2
xor a ; pixels OFF
setSPRinfodisable:ld (ix+4),a
ld (ix+0),a ; Y hors ecran
ld (ix+1),c ; Y hors ecran
ld (ix+2),a ; Y hors ecran
ld (ix+3),c ; Y hors ecran
add ix,de
djnz setSPRinfodisable
call AsicOff
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
enablesprite
call AsicOn
ld ix,#6000
ld de,8
ld b,16
ld a,%1001 ; hardware sprites in mode 1 - 15 colors
setSPRinfoenable:ld (ix+4),a
add ix,de
djnz setSPRinfoenable
call AsicOff
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;
; raz hardware sprites sequence
; as filling memory with zeros is very time consuming
; sprites has erased slowly, each call raz only a small portion
;
razsprite
ld a,0
add 2
ld (razsprite+1),a
jp z,endcopy
call AsicOn
sub 2
ld h,0
ld l,a
add hl,hl
add hl,hl
add hl,hl
add hl,hl ; x16
ld de,#4000
add hl,de
ld a,1
repeat 32
ld (hl),a
inc l
rend
call AsicOff
ret
endcopy
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;
; hardware sprite datas are in line
; torus in #0000
; logo in #4000
; cube in #8000
;
; data are not packed (remember this is a one week production!)
;
getcube:ld hl,8192
jr getput
gettorus:ld hl,0
jr getput
getlogo:ld hl,4096
getput:ld (getoffset+1),hl
jr getgeneric
; generic copy of data from memory to ASIC hardware sprite
; this is done by coying data 32 bytes by 32 bytes, using
; a buffer out of #4000 space since ASIC is also in #4000
;
getgeneric
getgenericcpt:ld a,0
add 2
ld (getgenericcpt+1),a
jr z,endcopy
ld bc,#7FC4
call ConnectRam
sub 2
ld h,0
ld l,a
add hl,hl
add hl,hl
add hl,hl
add hl,hl ; x16
ld de,#4000
add hl,de ; hl=adresse de depart du logo != adresse destination
push hl
getoffset:ld de,#1234
add hl,de ; hl=adresse de depart du logo / deuxieme position en bank
ld de,#1000
ld bc,32
ldir
ld bc,#7FC0
call ConnectRam
call AsicOn
ld hl,#1000
pop de
ld bc,32
ldir
call AsicOff
ret
;
; simply copy color values from memory to ASIC
; set HW sprites to mode 1 double size (or mode 0 double height)
;
setscrollcolor
call AsicOn
ld ix,#6000
ld hl,0
ld de,8
ld bc,64
ld hy,13
ScrollSpriteInitValues:
ld (ix+0),l
ld (ix+1),h
add hl,bc
ld (ix+3),0
ld (ix+4),2+4+8 ; mode 0 double en hauteur
add ix,de
dec hy
jr nz,ScrollSpriteInitValues
ld hl,SPRcolorScroll
ld de,#6422
ld bc,30
ldir
call AsicOff
; reset automod values
ld hl,#4000
ld (ScrollSpriteCurrentAdr+1),hl
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
ret
setcolorgeneric:
call AsicOn
ld de,#6422
ld bc,15*2
ldir
call AsicOff
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
settoruscolor:
ld hl,SPRcolorTorus
jr setcolorgeneric
setlogocolor
ld hl,SPRcolorLogo
jr setcolorgeneric
setcubecolor
ld hl,SPRcolorCube
jr setcolorgeneric
;****************************
movescroll:
call AsicOn
ld bc,#7FC1 ; bank 7 en #C000 FORCE / EXTENSION ADAPTATION
out (c),c
ScrollSpriteCharPhase: ld a,1 ; get next char
dec a
ld (ScrollSpriteCharPhase+1),a
call z,ScrollSpriteNextChar
ScrollSpriteCurrentAdr: ld hl,#4000
ScrollSpriteData: ld de,#1234
ld bc,16
repeat 16
ld a,(de)
inc de
ld (hl),a
add hl,bc
rend
ld bc,-255
add hl,bc
ld a,l
cp #10
jr nz,ScrollSpriteInc
ld l,0
inc h
ld a,h
cp #49
jr nz,ScrollSpriteInc
ld h,#40 ; on saute du sprite 9 au sprite 0
ScrollSpriteInc:
ld (ScrollSpriteCurrentAdr+1),hl
ex hl,de
ld (ScrollSpriteData+1),hl
; bouger les sprites d'un pixel mode 0
ScrollSpriteSinusPhase:ld a,#12
inc a
ld (ScrollSpriteSinusPhase+1),a
ld h,TABSIN256/256
ld l,a
ld a,(hl)
ld (ScrollSpriteSinusWave+3),a
ld ix,#6000
ld bc,-4
ld de,8
ld hy,13
ScrollSpriteMoveLoop:
ld l,(ix+0)
ld h,(ix+1)
add hl,bc
ld a,h
inc a
jr nz,ScrollSpriteMoveNext
ld a,l
cp 192
jr nz,ScrollSpriteMoveNext
ld hl,512
ScrollSpriteMoveNext:
ld (ix+0),l
ld (ix+1),h
ScrollSpriteSinusWave:ld (ix+2),#12
add ix,de
dec hy
jr nz,ScrollSpriteMoveLoop
call AsicOff
ret
ScrollSpriteNextChar:ld a,#12
dec a
ld (ScrollSpriteNextChar+1),a
bit 0,a
ld a,0
jr nz,ScrollSpriteNextCharInterSpace
ScrollSpriteTexteAdr: ld hl,ScrollSpriteTexte
ld a,(hl)
cp 254
call z,ScrollEnd
cp 255
jr nz,ScrollSpriteNextCharNoReset
ld hl,ScrollSpriteTexte
ld a,(hl)
ScrollSpriteNextCharNoReset:
inc hl
ld (ScrollSpriteTexteAdr+1),hl
add a
ScrollSpriteNextCharInterSpace:
ld l,a
ld h,#C0
ld e,(hl)
inc l
ld d,(hl)
ld l,0
add hl,de
ld a,(hl) ; get phase
ld (ScrollSpriteCharPhase+1),a
inc hl
ld (ScrollSpriteData+1),hl
ret
ScrollEnd
push hl
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
pop hl
ld a,1 ; espace
ret
;****************************
movelogo:ld a,152+1
dec a
jr z,movelogowait
ld (movelogo+1),a
call AsicOn
ld (movelogosp+1),sp
ld ix,#6000
ld sp,logopos
ld d,0
ld e,a
ld b,16
movelogoloop:
pop hl
ld (ix+0),l
ld (ix+1),h
pop hl
add hl,de
ld a,h
or a
ld a,0
jr nz,disablelogosprite ; clipping Y
ld a,9
disablelogosprite:
ld (ix+4),a
ld (ix+2),l
ld (ix+3),h
ld a,lx
add 8
ld lx,a
djnz movelogoloop
movelogosp: ld sp,#1234
call AsicOff
ret
movelogowait:ld hl,12*50
dec hl
ld (movelogowait+1),hl
ld a,h
or l
or a
ret nz
ld hl,12*50
ld (movelogowait+1),hl
ld a,152+1
ld (movelogo+1),a
; TODO
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;
; hardware sprites position for the logo
; those values are read and translated
;
logopos
defw 160,104,192,104,224,104,256,104,288,104,320,104
defw 160,120,192,120,224,120,256,120,288,120,320,120
defw 160,136, 224,136,256,136,288,136
;
; movetorus changes HW sprites positions regarding two sinus
; then switch all HW sprites positions to create an
; animation for each sprites
;
movetorus:
call AsicOn
phaseSPRX:ld hl,TABCOS512
inc l
ld (phaseSPRX+1),hl
; moveSPR
movSPRX:ld ix,#6000
ld de,8
add ix,de
ld a,lx
and #7F
ld lx,a
ld (movSPRX+2),ix
ld b,16
movetorusX:
ld a,(hl)
inc h
ld (ix+0),a
ld a,(hl)
dec h
ld (ix+1),a
ld a,l
add 7
ld l,a
add ix,de
ld a,lx
and #7F
ld lx,a
djnz movetorusX
phaseSPRY:ld hl,TABCOS512+256
dec l
ld (phaseSPRY+1),hl
; moveSPR
movSPRY:ld ix,#6000
ld de,8
add ix,de
ld a,lx
and #7F
ld lx,a
ld (movSPRY+2),ix
ld b,16
movetorusY:
ld a,(hl)
dec h
srl a
ld (ix+3),a
ld a,(hl)
rr a
inc h
ld (ix+2),a
ld a,l
add 9
ld l,a
add ix,de
ld a,lx
and #7F
ld lx,a
djnz movetorusY
call AsicOff
torusphase: ld hl,10*50
dec hl
ld (torusphase+1),hl
ld a,h
or l
or a
ret nz
ld hl,10*50
ld (torusphase+1),hl
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;
; same thing as movetorus, except X is fixed
;
movecube:
call AsicOn
ld iy,0
; moveSPR
cubemovSPRX:ld ix,#6000
ld de,8
add ix,de
ld a,lx
and #7F
ld lx,a
ld (cubemovSPRX+2),ix
ld b,16
movecubeX:
ld a,ly
ld (ix+0),a
ld a,hy
ld (ix+1),a
add ix,de
ld a,lx
and #7F
ld lx,a
push bc
ld bc,32
add iy,bc
pop bc
djnz movecubeX
cubephaseSPRY:ld hl,TABCOS512+256
dec l
ld (cubephaseSPRY+1),hl
; moveSPR
cubemovSPRY:ld ix,#6000
ld de,8
add ix,de
ld a,lx
and #7F
ld lx,a
ld (cubemovSPRY+2),ix
ld b,16
movecubeY:
ld a,(hl)
dec h
srl a
ld (ix+3),a
ld a,(hl)
rr a
inc h
ld (ix+2),a
ld a,l
add 9
ld l,a
add ix,de
ld a,lx
and #7F
ld lx,a
djnz movecubeY
call AsicOff
cubephase: ld hl,23*50
dec hl
ld (cubephase+1),hl
ld a,h
or l
or a
ret nz
ld hl,15*50
ld (cubephase+1),hl
ld hl,(hardware_sprite+1)
inc hl
inc hl
ld (hardware_sprite+1),hl
ret
;*******************************
;
; when putting dots on screen, we save screen adress with a PUSH
; the dots_clear function read the buffer, POP each value and clear screen
;
dots_clear:
ld (dots_clear_savpil+1),sp
dots_clear_readbuffer: ld sp,#1234
xor a
ld b,NBDOT/2
dots_clear_loop:
repeat 8
pop de
ld (de),a
rend
djnz dots_clear_loop
dots_clear_savpil: ld sp,#1234
ret
;
; dots_puts read X/Y stars, then apply it to the precomputed array
;
;
dots_put
ld (dots_put_savpil+1),sp
dots_clear_writebuffer:ld sp,#8000
ld b,NBDOT
ld ix,TABDOT
ld iy,TABMASK
exx
ld de,12
ld b,NBDOT
dots_put_loop:
exx
ld h,#30
ld l,(ix+11)
ld b,l
ld a,(hl)
inc h
ld d,(hl) ; de=screen adress, start of the subsection
inc h
ld l,(ix+5)
ld c,(hl) ; c is the pixel to put on screen
inc h
add (hl) ; da=screen adress, byte precise
ld e,a ; de=da
ld a,(iy+0) ; mask to set color according to the distance
and c
ld c,a ; patch mask
ld a,(de) ; get screen value
or c ; do fusion with new star
ld (de),a ; put to screen
push de ; save screen adress for clearscreen routine
; on the same line, do the sub and put pixel
inc h
ld a,e
sub (hl)
ld e,a
inc h
ld a,(hl)
and (iy+0)
ld c,a
ld a,(de)
or c
ld (de),a
inc h
push de
; -----upper screen display (almost the same code)-------
ld l,b
ld a,(hl)
inc h
ld d,(hl)
inc h
ld l,(ix+5)
ld c,(hl)
inc h
add (hl)
ld e,a
ld a,(iy+0)
and c
ld c,a
ld a,(de)
or c
ld (de),a
push de ; save screen adress for clearscreen routine
inc h
ld a,e
sub (hl)
ld e,a
inc h
ld a,(hl)
and (iy+0)
ld c,a
ld a,(de)
or c
ld (de),a
inc h
push de
exx
add ix,de
inc ly
djnz dots_put_loop
dots_put_savpil: ld sp,#1234
ret
;
; first version of stars where very slow cause i was doin' MUL
; twice per dot to make a true perspective compute
;
; this one is a faky perspective routine, doin' only additions
; i make two adds instead of one mul and additions ^_^
;
; the main principle is to do an acceleration so i add a value
; to an acceleration vector. Then i add this vector to the star
; position.
; The acceleration vector is initialized regarding of X/Y value
;
; this is very simple, very tricky, but it works and it's also
; damn FAAAAAAAAAAAAAAAASSSSSTTTT!!!
;
dots_move
ld bc,12
xor a
ld (dots_move_sp+1),sp
ld sp,TABDOT
ld hy,NBDOT
ld ix,TABDOT
dots_move_loop:
pop hl
pop de
add hl,de
ld (ix+2),l
ld (ix+3),h
pop de
add hl,de
bit 7,h
jr nz,dotreset1 ; star out of the screen if >127
ld (ix+4),l
ld (ix+5),h
pop hl
pop de
add hl,de
ld (ix+8),l
ld (ix+9),h
pop de
add hl,de
bit 7,h
jr nz,dotreset2 ; star out of the screen if >127
ld (ix+10),l
ld (ix+11),h
nextmove:
add ix,bc
dec hy
jr nz,dots_move_loop
dots_move_sp: ld sp,#1234
ret
; stars out of the screen are relocated to #0000
; so they are waiting a new value from the generator
dotreset1:
ld hl,6
add hl,sp
ld sp,hl
dotreset2:
ld (dotresetsavsp+1),sp
ld h,a
ld l,a
push hl
push hl
push hl
push hl
push hl
push hl
dotresetsavsp:ld sp,#1234
jr nextmove
;RAM
;incx; stepx; x
;incy; stepy; y
;
; Stars generation - 3 robots
;
; robot1: random values
; rotbo2: sinus tricks
; robot3: sinus tricks, slightly different
;
genestarentry:
ld a,(genestar+1)
dec a
ld l,a
ld a,64
sub l
; we create a counter from 0 to 63 with another counter from 64 to 1
; then we make an array of pixels MASKs to apply colors regarding from deep of star
;
ld hl,TABMASK
ld c,#3F
inc a
and c ; next from current generated star are the olders, so they are white bright!
ld l,a
ld b,10
ld d,#FF ; white bright mask
color_loop1:ld (hl),d
inc a
and c
ld l,a
ld (hl),d
inc a
and c
ld l,a
djnz color_loop1
ld (hl),d
inc a
and c
ld l,a
ld d,#0F ; bright grey mask
ld b,10
color_loop2:
ld (hl),d
inc a
and c
ld l,a
ld (hl),d
inc a
and c
ld l,a
djnz color_loop2
ld (hl),d
inc a
and c
ld l,a
ld d,#F0 ; dark grey mask
ld b,11
color_loop3:
ld (hl),d
inc a
and c
ld l,a
ld (hl),d
inc a
and c
ld l,a
djnz color_loop3
;
; one new star each VBL
;
genestar:
ld a,NBDOT
dec a
ld (genestar+1),a
jr nz,genestar_noreset
ld hl,TABDOT
ld (genestar_noreset+2),hl
ld a,NBDOT
ld (genestar+1),a
genestar_noreset:
ld ix,TABDOT
automatecall: call automate1 ; which robot to call for star generation?
; init stepx,incx,stepy,incy
ld d,0
; ld e,srl(ix+5)
defb #DD,#CB,5,#3B
ld (ix+0),e
ld (ix+2),e
ld (ix+1),d
ld (ix+3),d
; ld e,srl(ix+11)
defb #DD,#CB,11,#3B
ld (ix+6),e
ld (ix+8),e
ld (ix+7),d
ld (ix+9),d
ld bc,12
add ix,bc
ld (genestar_noreset+2),ix
;
; robots are looping
;
automatephase: ld hl,30*50
dec hl
ld (automatephase+1),hl
ld a,h
or l
or a
ret nz
ld hl,30*50
ld (automatephase+1),hl
automatecycle: ld hl,automates
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld a,e
or d
or a
jr z,automatereboot
ld (automatecycle+1),hl
ld (automatecall+1),de
ret
automatereboot:
ld hl,automates
ld (automatecycle+1),hl
jr automatecycle
automates
defw automate2,automate3,automate1,0
; AUTOMATE 1 random
automate1:
xor a
ld (ix+4),a
ld (ix+10),a
call random
and #3F
ld (ix+5),a
call random
and #3F
ld (ix+11),a
ret
; AUTOMATE 2 'legacy' generation -> 18 years old generation!
automate2:
xor a
ld (ix+4),a
ld (ix+10),a
ang:ld hl,0
phz:ld de,#90
add hl,de
ld (ang+1),hl
ld l,h
ld h,TABCOS256/256
ld a,(hl)
and #3F
ld (ix+5),a
ld a,l
add 30
ld l,a
ld a,(hl)
and #3F
ld (ix+11),a
automatenext:ld a,64
dec a
ld (automatenext+1),a
ret nz
ld a,64
ld (automatenext+1),a
ld de,#7
ld hl,(phz+1)
add hl,de
ld (phz+1),hl
ret
; AUTOMATE 3 - new robot, for fun, slightly different
automate3:
xor a
ld (ix+4),a
ld (ix+10),a
mat3p: ld a,0
inc a
ld (mat3p+1),a
ld l,a
ld h,TABCOS256/256
ld a,(hl)
and #3F
ld (ix+5),a
mat3p2:ld a,7
add l
ld l,a
ld a,(hl)
and #3F
ld (ix+11),a
mat3p3:ld a,0
dec a
ld (mat3p3+1),a
ret nz
ld a,(mat3p2+1)
inc a
ld (mat3p2+1),a
ret
;----------------- init a screen 256x256 pixels mode 1
crtc_init_cubic_screen:
ld hl,crtc_cubic_screen
ld bc,#bc00
crtc_init_cubic_loop:
ld a,(hl)
cp 255
ret z
out (c),a
inc hl
ld a,(hl)
inc hl
inc b
out (c),a
dec b
jr crtc_init_cubic_loop
crtc_cubic_screen:
defb 6,32,1,32,2,42,7,34,255
; Created by Patrik Rak in 2008 and revised in 2011/2012.
random:
ld hl,#A280 ; yw -> zt
ld de,#C0DE ; xz -> yw
ld (random+4),hl ; x = y, z = w
ld a,l ; w = w ^ ( w << 3 )
add a,a
add a,a
add a,a
xor l
ld l,a
ld a,d ; t = x ^ (x << 1)
add a,a
xor d
ld h,a
rra ; t = t ^ (t >> 1) ^ w
xor h
xor l
ld h,e ; y = z
ld l,a ; w = t
ld (random+1),hl
ret
vbl
ld bc,#7FC6
call ConnectRam
ld de,#49A8
call #4003 ; arkos player
ld b,#F5
vbloop: in a,(c)
rra
jr nc,vbloop
ret
ConnectRam:
out (c),c
ex af,af'
ld a,c
ld (ramsav+1),a ; save ram state before connect
ex af,af'
ret
AsicOn:LD BC,#7FB8
OUT (C),C
LD BC,#7FC0
out (c),c
ret
AsicOff:LD BC,#7FA0
OUT (C),C
ld b,#7F
ramsav:ld c,#C0 ; redo a RAM connection after AsicOFF
out (c),c
ret
UnlockAsic:
LD E,17
LD HL,ASIC
LD BC,#BC00
UnlockLoop LD A,(HL)
OUT (C),A
INC HL
DEC E
JR NZ,UnlockLoop
RET
ASIC DEFB 255,0,255,119,179
DEFB 81,168,212,98,57,156
DEFB 70,43,21,138,205,238
SPRcolorTorus: defw #0110,#0220,#0320,#0431,#0541,#0551,#0652,#0762,#0872,#0983,#0B93,#0CB4,#0EC5,#0FE6,#FFF
SPRcolorLogo: defw #0000,#0152,#0274,#0377,#0487,#0588,#0788,#0888,#0B87,#0A98,#0BB7,#0CB8,#0DBD,#0EDF,#0FFF
SPRcolorScroll: defw #0111,#0333,#0555,#0666,#0777,#0888,#0999,#0AAA,#0BBB,#0CCC,#0DDC,#0DDD,#0EEE,#0FFE,#0FFF
SPRcolorCube: defw #0112,#0223,#0234,#0346,#0457,#0578,#068A,#079C,#08BD,#09CF,#0ADF,#0BEF,#0CFF,#0EFF,#0FFF
org #9400
db #a0,#9f,#9f,#9f,#9f,#9e,#9e,#9d
db #9c,#9c,#9b,#9a,#99,#97,#96,#95
db #93,#92,#90,#8e,#8d,#8b,#89,#87
db #85,#82,#80,#7e,#7b,#79,#76,#73
db #71,#6e,#6b,#68,#65,#62,#5f,#5c
db #58,#55,#52,#4e,#4b,#47,#44,#40
db #3d,#39,#35,#32,#2e,#2a,#26,#23
db #1f,#1b,#17,#13,#0f,#0b,#07,#03
db #00,#03,#06,#09,#0d,#10,#13,#17
db #1a,#1d,#20,#24,#27,#2a,#2d,#30
db #33,#36,#39,#3c,#3f,#42,#45,#48
db #4b,#4d,#50,#53,#55,#58,#5a,#5d
db #5f,#61,#64,#66,#68,#6a,#6c,#6e
db #70,#72,#73,#75,#77,#78,#7a,#7b
db #7c,#7d,#7f,#80,#81,#82,#82,#83
db #84,#85,#85,#85,#86,#86,#86,#86
db #86,#86,#86,#86,#86,#85,#85,#85
db #84,#83,#82,#82,#81,#80,#7f,#7d
db #7c,#7b,#7a,#78,#77,#75,#73,#72
db #70,#6e,#6c,#6a,#68,#66,#64,#61
db #5f,#5d,#5a,#58,#55,#53,#50,#4d
db #4b,#48,#45,#42,#3f,#3c,#39,#36
db #33,#30,#2d,#2a,#27,#24,#20,#1d
db #1a,#17,#13,#10,#0d,#09,#06,#03
db #00,#02,#05,#08,#0a,#0d,#10,#12
db #15,#18,#1a,#1d,#1f,#22,#25,#27
db #2a,#2c,#2f,#31,#33,#36,#38,#3a
db #3d,#3f,#41,#43,#45,#47,#49,#4b
db #4d,#4f,#51,#53,#55,#56,#58,#59
db #5b,#5c,#5e,#5f,#61,#62,#63,#64
db #65,#66,#67,#68,#69,#6a,#6a,#6b
db #6b,#6c,#6c,#6d,#6d,#6d,#6d,#6d
; cosinus
db #dd,#dd,#dd,#dc,#dc,#db,#da,#d9
db #d8,#d7,#d6,#d4,#d3,#d1,#cf,#cd
db #cb,#c9,#c6,#c4,#c1,#be,#bb,#b8
db #b5,#b2,#ae,#ab,#a7,#a3,#9f,#9b
db #97,#93,#8f,#8a,#86,#81,#7d,#78
db #73,#6e,#69,#64,#5f,#5a,#55,#4f
db #4a,#45,#3f,#3a,#34,#2e,#29,#23
db #1d,#18,#12,#0c,#06,#01,#fb,#f5
db #ef,#e9,#e3,#dd,#d8,#d2,#cc,#c6
db #c1,#bb,#b5,#b0,#aa,#a4,#9f,#99
db #94,#8f,#89,#84,#7f,#7a,#75,#70
db #6b,#66,#61,#5d,#58,#54,#4f,#4b
db #47,#43,#3f,#3b,#37,#33,#30,#2c
db #29,#26,#23,#20,#1d,#1a,#18,#15
db #13,#11,#0f,#0d,#0b,#0a,#08,#07
db #06,#05,#04,#03,#02,#02,#01,#01
db #01,#01,#01,#02,#02,#03,#04,#05
db #06,#07,#08,#0a,#0b,#0d,#0f,#11
db #13,#15,#18,#1a,#1d,#20,#23,#26
db #29,#2c,#30,#33,#37,#3b,#3f,#43
db #47,#4b,#4f,#54,#58,#5d,#61,#66
db #6b,#70,#75,#7a,#7f,#84,#89,#8f
db #94,#99,#9f,#a4,#aa,#b0,#b5,#bb
db #c1,#c6,#cc,#d2,#d8,#dd,#e3,#e9
db #ef,#f5,#fb,#01,#06,#0c,#12,#18
db #1d,#23,#29,#2e,#34,#3a,#3f,#45
db #4a,#4f,#55,#5a,#5f,#64,#69,#6e
db #73,#78,#7d,#81,#86,#8a,#8f,#93
db #97,#9b,#9f,#a3,#a7,#ab,#ae,#b2
db #b5,#b8,#bb,#be,#c1,#c4,#c6,#c9
db #cb,#cd,#cf,#d1,#d3,#d4,#d6,#d7
db #d8,#d9,#da,#db,#dc,#dc,#dd,#dd
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #00,#03,#06,#09,#0b,#0e,#11,#13
db #16,#19,#1c,#1e,#21,#24,#27,#2a
db #2c,#2f,#31,#34,#37,#3a,#3c,#3f
db #42,#44,#47,#49,#4c,#4f,#52,#54
db #56,#59,#5b,#5e,#61,#63,#66,#69
db #6a,#6d,#6f,#72,#74,#77,#79,#7c
db #7d,#80,#82,#84,#87,#89,#8b,#8e
db #8f,#91,#93,#96,#98,#9a,#9c,#9e
db #a0,#a2,#a3,#a5,#a7,#a9,#ab,#ad
db #af,#b1,#b3,#b4,#b5,#b7,#b9,#ba
db #bc,#bd,#bf,#c1,#c2,#c4,#c5,#c7
db #c8,#c8,#ca,#cb,#cc,#cd,#cf,#d0
db #d1,#d2,#d3,#d4,#d5,#d6,#d7,#d8
db #d9,#da,#da,#db,#db,#dc,#dc,#dd
db #dd,#de,#de,#df,#df,#e0,#e0,#e1
db #e1,#e1,#e1,#e2,#e2,#e2,#e2,#e2
db #e2,#e2,#e2,#e2,#e2,#e2,#e1,#e1
db #e1,#e1,#e0,#e0,#df,#df,#de,#de
db #dd,#dd,#dc,#dc,#db,#db,#da,#da
db #d9,#d8,#d7,#d6,#d5,#d4,#d3,#d2
db #d1,#d0,#cf,#cd,#cc,#cb,#ca,#c8
db #c8,#c7,#c5,#c4,#c2,#c1,#bf,#bd
db #bc,#ba,#b9,#b7,#b5,#b4,#b3,#b1
db #af,#ad,#ab,#a9,#a7,#a5,#a3,#a2
db #a0,#9e,#9c,#9a,#98,#96,#93,#91
db #8f,#8e,#8b,#89,#87,#84,#82,#80
db #7d,#7c,#79,#77,#74,#72,#6f,#6d
db #6a,#69,#66,#63,#61,#5e,#5b,#59
db #56,#54,#52,#4f,#4c,#49,#47,#44
db #42,#3f,#3c,#3a,#37,#34,#31,#2f
db #2c,#2a,#27,#24,#21,#1e,#1c,#19
db #16,#13,#11,#0e,#0b,#09,#06,#03
thankyoudata
db #77,#ff,#44,#00,#00,#00,#00,#00
db #44,#00,#00,#00,#44,#11,#00,#00
db #00,#00,#00,#88,#44,#00,#00,#00
db #00,#00,#44,#00,#00,#00,#44,#11
db #00,#00,#00,#00,#00,#88,#77,#cc
db #33,#cc,#55,#cc,#44,#22,#00,#00
db #22,#22,#33,#cc,#44,#22,#00,#88
db #44,#22,#00,#22,#66,#22,#44,#44
db #00,#00,#11,#44,#44,#22,#44,#22
db #00,#88,#44,#22,#33,#ee,#44,#22
db #77,#88,#00,#00,#00,#88,#44,#22
db #44,#22,#00,#88,#44,#22,#44,#22
db #44,#22,#44,#44,#00,#00,#00,#88
db #44,#22,#44,#66,#00,#88,#44,#22
db #33,#ee,#44,#22,#44,#22,#00,#00
db #00,#88,#33,#cc,#33,#aa,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
ScrollSpriteTexte
db #18,#20,#27,#1e,#2a,#28,#20,#01
db #2f,#2a,#01,#2f,#23,#24,#2e,#01
db #1d,#2d,#1c,#29,#1f,#01,#29,#20
db #32,#01,#02,#28,#2e,#2f,#2d,#1c
db #1f,#01,#11,#27,#30,#2e,#01,#24
db #29,#2f,#2d,#2a,#44,#01,#0a,#2f
db #46,#2e,#01,#1d,#20,#20,#29,#01
db #1c,#01,#27,#2a,#29,#22,#01,#2f
db #24,#28,#20,#01,#2e,#24,#29,#1e
db #20,#01,#24,#01,#23,#1c,#1f,#01
db #2b,#30,#1d,#27,#24,#2e,#23,#20
db #1f,#01,#1c,#01,#04,#11,#04,#01
db #2b,#2d,#2a,#1f,#30,#1e,#2f,#24
db #2a,#29,#41,#01,#0e,#1c,#29,#34
db #01,#2b,#20,#2a,#2b,#27,#20,#01
db #2f,#2a,#27,#1f,#01,#28,#20,#01
db #2f,#2a,#01,#2d,#20,#27,#20,#1c
db #2e,#20,#01,#28,#34,#01,#2a,#27
db #1f,#01,#2b,#2d,#20,#31,#24,#20
db #32,#2e,#40,#01,#27,#24,#26,#20
db #01,#2f,#23,#24,#2e,#01,#2e,#2f
db #1c,#2d,#21,#24,#20,#27,#1f,#01
db #24,#01,#2e,#2f,#1c,#2d,#2f,#20
db #1f,#01,#38,#36,#01,#34,#20,#1c
db #2d,#2e,#01,#1c,#22,#2a,#41,#41
db #41,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#18,#23,#1c,#2f,#01
db #34,#2a,#30,#01,#2e,#20,#20,#01
db #24,#2e,#01,#1c,#01,#1e,#27,#20
db #1c,#29,#01,#2d,#20,#1d,#2a,#2a
db #2f,#01,#2a,#21,#01,#2f,#23,#20
db #01,#2b,#2d,#20,#31,#24,#2a,#30
db #2e,#01,#1e,#2a,#1f,#20,#41,#01
db #0a,#01,#29,#20,#31,#20,#2d,#01
db #2d,#20,#27,#20,#1c,#2e,#20,#01
db #2f,#23,#20,#01,#2a,#27,#1f,#01
db #14,#2f,#1c,#2d,#21,#24,#20,#27
db #1f,#01,#1e,#1c,#30,#2e,#20,#01
db #24,#2f,#01,#32,#1c,#2e,#01,#05
db #02,#0e,#0f,#01,#2e,#27,#2a,#32
db #01,#47,#37,#38,#41,#3b,#09,#35
db #48,#44,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01
db #0f,#2a,#32,#01,#2f,#23,#24,#2e
db #01,#2a,#29,#20,#01,#24,#2e,#01
db #3b,#36,#09,#35,#01,#42,#48,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01
db #01,#01,#01,#fe,#01,#0a,#01,#23
db #2a,#2b,#20,#01,#34,#2a,#30,#01
db #27,#24,#26,#20,#01,#28,#34,#01
db #1f,#2a,#29,#30,#2f,#2e,#01,#2f
db #2a,#2a,#44,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#09,#20,#2d,#20,#01
db #1c,#2d,#20,#01,#2f,#23,#20,#01
db #1e,#2d,#20,#1f,#24,#2f,#2e,#01
db #21,#2a,#2d,#01,#2f,#23,#24,#2e
db #01,#2e,#28,#1c,#27,#27,#01,#24
db #29,#2f,#2d,#2a,#41,#41,#41,#01
db #01,#01,#01,#01,#01,#1e,#2a,#1f
db #20,#42,#01,#2d,#2a,#30,#1f,#2a
db #30,#1f,#2a,#30,#01,#43,#01,#07
db #27,#2a,#32,#20,#2d,#01,#04,#2a
db #2d,#2b,#41,#01,#01,#01,#01,#01
db #01,#27,#2a,#22,#2a,#42,#01,#07
db #2d,#1c,#01,#43,#01,#0e,#1c,#29
db #1f,#1c,#2d,#24,#29,#20,#01,#01
db #01,#01,#01,#01,#01,#35,#24,#26
db #42,#01,#15,#2a,#28,#01,#20,#2f
db #01,#0b,#20,#2d,#2d,#34,#01,#43
db #01,#08,#11,#02,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#28,#2a,#2d
db #1c,#27,#01,#2e,#30,#2b,#2b,#2a
db #2d,#2f,#42,#01,#0a,#2d,#2a,#29
db #01,#1c,#29,#1f,#01,#0d,#20,#01
db #1f,#1c,#2d,#2a,#29,#01,#20,#29
db #01,#2b,#30,#27,#27,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#fe,#08,#2d,#20
db #20,#2f,#24,#29,#22,#2e,#01,#22
db #2a,#20,#2e,#01,#2f,#2a,#01,#02
db #2d,#26,#2a,#2e,#01,#43,#01,#03
db #1c,#2f,#28,#1c,#29,#01,#22,#2d
db #2a,#30,#2b,#01,#43,#01,#03,#20
db #29,#20,#1f,#24,#1e,#2f,#24,#2a
db #29,#01,#43,#01,#04,#2a,#29,#1f
db #20,#29,#2e,#20,#01,#43,#01,#05
db #24,#2d,#2f,#34,#01,#0e,#24,#29
db #1f,#2e,#01,#43,#01,#07,#30,#2f
db #30,#2d,#2e,#01,#43,#01,#08,#11
db #02,#01,#43,#01,#09,#1c,#2d,#1f
db #46,#10,#14,#01,#43,#01,#0a,#28
db #2b,#1c,#1e,#2f,#01,#43,#01,#0d
db #2a,#22,#2a,#29,#01,#14,#34,#2e
db #2f,#20,#28,#01,#43,#01,#10,#17
db #0d,#01,#43,#01,#17,#1c,#29,#24
db #2f,#34,#01,#1c,#29,#1f,#01,#05
db #2d,#01,#1a,#20,#2e,#01,#2b,#1c
db #2d,#1e,#20,#01,#2c,#30,#46,#24
db #27,#01,#1c,#24,#28,#20,#01,#27
db #20,#2e,#01,#1d,#24,#2e,#2a,#30
db #2e,#44,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#01,#01,#01
db #01,#01,#01,#01,#01,#fe,#ff,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00,#00,#00
db #00,#00,#00,#00,#00,#00