;ANGELS4.S
;*********
;by NINJA of ANGELS
; (c) 1991

org $30000
load $30000


>extern "logo",bob
>extern "star2",motif
>extern "fonte3",fonte
>extern "mad",data

;RI:
;LOGO-->BOB
;STAR2-->MOTIF
;FONTE3-->FONTE
;PARANOIMIA-->DATA
;les choix sont places au labels :
;lives/credits/weapons/collisions/level (l.731)
;toute modification de ces parametres au depart 
;devra etre suivie d'une modification des messages (l.758)
;suivant les valeurs des parametres mettre en oeuvre le -TRAINER-
go:
level_max = 8 ; nombre de tableaux maximum dans le jeu
nombre_choix = 5 ; nombre de choix dans le menu (1 à 6)
nmin = 6-nombre_choix
wot = 10 ;--->speed mouse
rvb = $777 ;couleur du texte menu
planesize1 = 46*112
size1 = 4*46*112
planesize2 = 46*112
size2 = 46*112
planesize3 = 50*50
size3 = 50*50
largeur = 46; largeur bitplan
largeur2 = 32 ; largeur bob
size_image = 3200 ; taille d'un bitplan bob
size_bitplan = planesize1
taille_cop = 9000
bsize = 5000
bsr save_all

bset #1,$bfe001
move.l 4,a6
move.l #10808,d0
move.l #$50914,a1
jsr -204(a6)
move.l #size1,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,image1
move.l #size2,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,image2
move.l #size3,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,image3
move.l #taille_cop,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,copper_list
bsr make_cl
bsr initstars
bsr init_menu
move.l #data,a0
move.l #$40000,a1
move.w #[9408/4],d3
copmus:
move.L (a0)+,(a1)+
dbra d3,copmus
JSR $40000
bsr sprite_colors
lea $dff000,a6
move.w #$03e0,$096(a6)
move.l copper_list,$80(a6)
clr.w $88(a6)
move.w #$87e0,$096(a6)
move.l $6c.w,saut_irq+2
move.l #irq,$6c
move.w #$3fff,$9a(a6)
move.w #$c010,$9a(a6)
att:
move.w d7,d6
move.w $dff00a,d7
sub.w d7,d6
cmp.w #$0100,d6
beq ady
cmp.w #$ff00,d6
beq suby 
att2:
cmp.w #1,retour
bne att
bra fin
ady:
move.w #2,ay
bra att2
suby:
move.w #1,ay
bra att2
fin:
jsr $40000
bclr #1,$bfe001
move.l 4,a6
move.l #$50914,a1
move.l #10808,d0
jsr -210(a6)
move.l spritedata,a1
move.l #bsize,d0
jsr -210(a6)
move.l spritedata2,a1
move.l #bsize,d0
jsr -210(a6)
move.l image1,a1
move.l #size1,d0
jsr -210(a6)
move.l image2,a1
move.l #size2,d0
jsr -210(a6)
move.l image3,a1
move.l #size3,d0
jsr -210(a6)
move.l copper_list,a1
move.l #taille_cop,d0
jsr -210(a6)

bsr restore_all

MOVE.W CREDITS,$100.W
MOVE.W WEAPONS,$102.W
MOVE.W COLLISIONS,$104.W
MOVE.W LEVEL,$106.W


moveq #0,d0
rts
save_all:
move.b #%10000111,$bfd100
move.l 4,a6
jsr -132(a6)
move.l $6c,save_vect_irq
move.w $dff01c,save_intena
or.w #$c000,save_intena
move.w $dff002,save_dmacon
or.w #$8100,save_dmacon
rts

restore_all:
move.w #$000f,$dff096
move.w #$4000,$dff09a
move.l save_vect_irq,$6c
move.w #$7fff,$dff09a
move.w save_intena,$dff09a
move.w #$7fff,$dff096
move.w save_dmacon,$dff096
move.l 4,a6
lea name_glib,a1
moveq #0,d0
jsr -552(a6)
move.l d0,a0
move.l 38(a0),$dff080
clr.w $dff088
jsr -138(a6)
move.l d0,a1
jsr -414(a6)
rts

save_intena:dc.w 0
save_dmacon:dc.w 0
save_vect_irq:dc.l 0
name_glib:dc.b "graphics.library",0
even
initstars:
move.l 4,a6
move.l copper_list,a0
move.l #clr,a1
move.l a1,d1
move.w #7,d3
clrsp:
move.w d1,6(a0)
swap d1
move.w d1,2(a0)
swap d1
add.l #8,a0
dbra d3,clrsp

move.l #bsize,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,spritedata
move.l copper_list,a0
add.l #2,a0
move.b #48,d1
move.b #8,d7
move.l #motif,mot
bsr initstar2

move.l #bsize,d0
move.l #$10002,d1
jsr -198(a6)
move.l d0,spritedata2
move.l copper_list,a0
add.l #10,a0
move.b #48+16,d1
move.b #8,d7
move.l #motif,mot
bsr initstar2
rts
initstar2:
swap d0
move.w d0,(a0)
swap d0
move.w d0,4(a0)
move.l d0,a0
move.b d1,d0
remplit1:
move.b d0,(a0)+
move.b d2,(a0)+
add.b d7,d0
move.b d0,(a0)+
clr.b (a0)+
move.l mot,a1
move.l a1,a2
add.l #16,a2
moveq #7,d3
copie:
move.w (a1)+,(a0)+
move.w (a2)+,(a0)+
dbra d3,copie

add.b d7,d0
add.l a0,d2
sub.b d0,d2
tst.b d0
bne.s remplit1
remplit2:
move.b d0,(a0)+
move.b d2,(a0)+
add.b d7,d0
move.b d0,(a0)+
move.b #6,(a0)+
move.l mot,a1
move.l a1,a2
add.l #16,a2
moveq #7,d3
copie2:
move.w (a1)+,(a0)+
move.w (a2)+,(a0)+
dbra d3,copie2
add.b d7,d0
add.l a0,d2
sub.b d0,d2
cmp.b #48,d0
bne.s remplit2
rts

movestars:

move.l spritedata,a0
bsr movestars2
move.l spritedata2,a0
bsr movestars3
rts
movestars2:
moveq #32,d0
stscrolld:
addq.b #2,1(a0)
addq.b #3,37(a0)
addq.b #4,73(a0)
addq.b #5,109(a0)
add.l #144,a0
dbra d0,stscrolld
rts
movestars3:
moveq #32,d0
stscrolld2:
addq.b #2,1(a0)
addq.b #3,37(a0)
addq.b #4,73(a0)
addq.b #5,109(a0)
add.l #144,a0
dbra d0,stscrolld2
rts
make_cl:
move.l #copperdata,a1
move.l copper_list,a0
move.w #23,d3
lo1:
move.l (a1)+,(a0)+
dbra d3,lo1
move.l #$01800000,(a0)+
move.l #$01004200,(a0)+
make_colors:
move.l #bob,a1
add.l #12800,a1
move.w #15,d3
move.w #$180,a2
loop1:
move.w a2,(a0)+
move.w (a1)+,(a0)+
add.w #2,a2
dbra d3,loop1
move.l image1,d1
moveq #3,d4
move.w #$0e0,d3
loop2:
move.w d3,(a0)+
addq.w #2,d3
swap d1
move.w d1,(a0)+
move.w d3,(a0)+
addq.w #2,d3
swap d1
move.w d1,(a0)+
add.l #planesize1,d1
dbra d4,loop2
move.l #$a001fffe,(a0)+
move.l #$01001200,(a0)+
move.l image2,d1
move.w #$0e0,d3
move.w d3,(a0)+
addq.w #2,d3
swap d1
move.w d1,(a0)+
move.w d3,(a0)+
swap d1
move.w d1,(a0)+
move.l #copperdata2,a1
move.w #17,d3
copp:
move.l (a1)+,(a0)+
dbra d3,copp
move.l image3,d1
move.w #$0e0,d3
move.w d3,(a0)+
addq.w #2,d3
swap d1
move.w d1,(a0)+
move.w d3,(a0)+
swap d1
move.w d1,(a0)+
moveq #15,d3
move.l #red,a1
move.l #$1001fffe,d1
degg:
move.l d1,(a0)+
move.w #$0182,(a0)+
move.w (a1)+,(a0)+
add.l #$01000000,d1
dbra d3,degg 
endcpl:
move.l #$009c8010,(a0)+
move.l #$fffffffe,(a0)+
rts

IRQ:
movem.l d0-d7/a0-a6,-(sp)
move.w $dff01c,d0
and.w $dff01e,d0
btst #4,d0
beq FIN_IRQ
bsr movestars
bsr move_bob
bsr scrolltext
bsr menu
jsr $40208
move.w #$10,$dff09c
FIN_IRQ:
movem.l (sp)+,d0-d7/a0-a6
saut_irq: jmp 0.l
move_bob:

move.l mocu,d2
cmp.l #txf,d2
bne epl
move.l #tx,mocu
epl:
move.l mocu,a0
move.w (a0),d0
add.l #2,mocu
move.l #bob,a0
move.l image1,a1
draw_bob:
movem.l d0-d2/a0-a2,-(sp)
move.w d0,d2
lsr.w #3,d0
and.w #$fffe,d0
and.w #$f,d2
add.w #276,d0
add.w d0,a1
ror.w #4,d2
or.w #$09f0,d2
move.w d2,$dff040
move.l #$ffff0000,$dff044
move.w #0,$dff064
move.w #[largeur-largeur2],$dff066
moveq #3,d3
copi:
waitblt:
btst #14,$dff002
bne waitblt
move.l a0,$dff050
move.l a1,$dff054
move.w #14,$dff066
move.w #6416,$dff058
add.l #size_image,a0
add.l #size_bitplan,a1
dbra d3,copi
movem.l (sp)+,d0-d2/a0-a2
rts
menu:
bsr menu2
cmp.w #5,y_mouse
bne suy
btst #6,$bfe001
bne suy
move.w #1,retour
suy:
rts
sprite_colors:
move.l #colorsprite,a1
move.w #3,d3
move.l #$dff1a0,a0
ccs:
move.w (a1)+,(a0)+
dbra d3,ccs
rts

scrolltext:
add.w #1,compteur
cmp.w #4,compteur
beq cherchecaract
bsr scrollbande
rts
cherchecaract:
clr.w compteur
move.l ptrlettre,a2
move.b (a2),d0
bsr incremcaract
cmp.b #' ',d0
blt space
cmp.b #'Z',d0
bhi space
bra nospecial
space:
move.b #' ',d0
nospecial:
move.b d0,d7
bsr scrollbande
adrlettre:
lea tablelettres,a3
sub.b #' ',d0
and.w #$00ff,d0
lsl.w #2,d0
move.l #fonte,a1
add.l 0(a3,d0.w),a1
move.l image3,a0
add.l #46,a0
insert:
move.l a1,$dff050
move.l a0,$dff054
move.w #38,$dff064
move.l #$09f00000,$dff040
move.l #$ffffffff,$dff044
move.w #48,$dff066
move.w #16*64+1,$dff058
rts
scrollbande:
waik:
btst #$e,$dff002
bne waik
move.l image3,a0
move.l a0,a1
sub.l #2,a1
scrolle:
move.l a0,$dff050
move.l a1,$dff054
move.w #0,$dff064
move.w #0,$dff066
move.l #$c9f00000,$dff040
move.l #$ffffffff,$dff044
move.w #16*64+25,$dff058
rts
incremcaract:
add.l #1,ptrlettre
cmp.l #fintexte,ptrlettre
bne pasfintexte
move.l #debuttexte,ptrlettre
pasfintexte:
rts
init_menu:
move.l image2,a0
add.l #4,a0
lea message1,a1
bsr affor
lea message2,a1
bsr affor
lea message3,a1
bsr affor
lea message4,a1
bsr affor
lea message5,a1
bsr affor
lea message6,a1
bsr affor
rts
affor:
move.l a0,a2
move.w #19,d3
write:
move.b (a1)+,d0
lea tablelettres,a3
sub.b #' ',d0
and.w #$00ff,d0
lsl.w #2,d0
move.l #fonte,a4
add.l 0(a3,d0.w),a4
move.l a4,$dff050
move.l a2,$dff054
move.w #38,$dff064
move.l #$09f00000,$dff040
move.l #$ffffffff,$dff044
move.w #44,$dff066
move.w #16*64+1,$dff058
add.l #2,a2
dbra d3,write
add.l #736,a0
rts
menu2:
move.l copper_list,a0
add.l #212,a0
move.w #nmin,d0
move.w #nombre_choix,d1
lsl.w #3,d0
add.l d0,a0
sub.w #1,d1
cln:
move.w #rvb,6(a0)
add.l #8,a0
dbra d1,cln

cont_menu:
move.w y_mouse,d0
move.l copper_list,a0
add.l #212,a0
lsl.w #3,d0
add.l d0,a0
move.l colle,d2
cmp.l #colf,d2
bne hpl
move.l #col,colle
hpl:
move.l colle,a1
cmp.w #2,timerk
bne ipl
add.l #2,colle
clr.w timerk
ipl:
add.w #1,timerk
move.w (a1),6(a0)
move.w y_mouse,d1
move.l #lives,a1
lsl.w #1,d1
add.l d1,a1
cmp.w #4,y_mouse
beq inc_level
yoko:
btst #10,$dff016
beq rightap
clr.w fd
rightap:
btst #6,$bfe001
beq leftap
clr.w fe
leftap:
btst #10,$dff016
beq off
btst #6,$bfe001
beq on
cmp.w #1,ay
beq ady_mouse
cmp.w #2,ay
beq suby_mouse
ko:
rts
inc_level:
cmp.w #1,fd
beq yoko
btst #10,$dff016
bne sub_level
move.w #1,fd
cmp.w #level_max,level
beq sub_level
add.w #1,(a1)
bsr affiche_level
sub_level:
cmp.w #1,fe
beq yoko
btst #6,$bfe001
bne YOKO
move.w #1,fe
cmp.w #1,level
beq YOKO
sub.w #1,(a1)
bsr affiche_level
bra yoko
affiche_level:
move.w level,d0
lea tablelevels,a1
mulu #3,d0
add.l d0,a1
move.w y_mouse,d0
move.l image2,a0
add.l #4,a0
add.l #34,a0
mulu #736,d0
add.l d0,a0
move.w #2,d3
move.l a0,a2
bsr write
rts
on:
cmp.w #4,y_mouse
beq ko
move.w #1,(a1)
bsr w_on
bra ko
off:
cmp.w #4,y_mouse
beq ko
move.w #0,(a1)
bsr w_off
bra ko
w_on:
cmp.w #4,y_mouse
bge w_ond

lea messon,a1
bsr xyz
w_ond:
rts
w_off:
cmp.w #4,y_mouse
bge w_offd
lea messof,a1
bsr xyz
w_offd:
rts
xyz:
move.w y_mouse,d0
move.l image2,a0
add.l #4,a0
add.l #34,a0
mulu #736,d0
add.l d0,a0
move.w #2,d3
move.l a0,a2
bsr write
rts
suby_mouse:
clr.w ay
add.w #1,c1
cmp.w #wot,c1
bne ko
clr.w c1
sub.w #1,y_mouse
cmp.w #nmin,y_mouse
blt cy1
subf:
bra ko
cy1:
move.w #nmin,y_mouse
bra ko
ady_mouse:
clr.w ay
add.w #1,c2
cmp.w #wot,c2
bne ko
clr.w c2
add.w #1,y_mouse
cmp.w #5,y_mouse
bgt cy2
adf:
bra ko
cy2:
move.w #5,y_mouse
bra ko

ay:dc.w 0
fd:dc.w 0
fe:dc.w 0
c1:dc.w 0
c2:dc.w 0
timerk:dc.w 0
compteur:dc.w 0
ptrlettre:dc.l debuttexte
colle:dc.l col
image1 : dc.l 0
image2 : dc.l 0
image3 : dc.l 0
copper_list:dc.l 0
spritedata:dc.l 0
spritedata2:dc.l 0
clr:dc.l 0
emplc:dc.l 0
mot:dc.l 0

col:
dc.w $000,$111,$222,$333,$444,$555,$666,$777,$888,$999
dc.w $aaa,$bbb,$ccc,$ddd,$eee
dc.w $ddd,$ccc,$bbb,$aaa,$999,$888,$777,$666,$555,$444
dc.w $333,$222,$111
colf:
mocu:dc.l tx
tx:;   (35 à 95)
dc.w 60
dc.w 61,62,61,60,59,58,59,60
dc.w 61,62,63,64,63,62,61,60,59,58,57,56,57,58,59,60
dc.w 62,64,66,68,66,64,62,60,58,56,54,52,54,56,58,60
dc.w 62,64,66,68,70,72,74,76,78,76,74,72,70,68,66,64,62,60
dc.w 58,56,54,52,50,48,46,44,42,44,46,48,50,52,54,56,58,60
dc.w 62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94
dc.w 92,90,88,86,84,82,80,78,76,74,72,70,68,66,64,62,60
dc.w 58,56,54,52,50,48,46,44,42,40,38,36,34,32,30,28,26
dc.w 28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60
dc.w 62,64,66,68,70,72,74,76,78,76,74,72,70,68,66,64,62,60
dc.w 58,56,54,52,50,48,46,44,42,44,46,48,50,52,54,56,58,60
dc.w 62,64,66,68,66,64,62,60,58,56,54,52,54,56,58,60
dc.w 61,62,63,64,63,62,61,60,59,58,57,56,57,58,59
dc.w 60,61,62,61,60,59,58,59
txf:
copperdata:
dc.l $01200000,$01220000,$01240000,$01260000
dc.l $01280000,$012a0000,$012c0000,$012e0000
dc.l $01300000,$01320000,$01340000,$01360000
dc.l $01380000,$013a0000,$013c0000,$013e0000
dc.l $008e3081,$009038f1,$00920028,$009400d8
dc.l $01080000,$010a0000,$01020000,$01040000
copperdata2:
dc.l $01820000,$b001fffe,$01820000,$c001fffe
dc.l $01820000,$d001fffe,$01820000,$e001fffe
dc.l $01820000,$f001fffe,$01820000,$ffdffffe
dc.l $01fe0000,$0011fffe,$01fe0000,$1001fffe
dc.l $01080004,$010a0004

retour: dc.w 0
; 1 = ON/0 = OFF
;------------------------------
LIVES : DC.W 01
CREDITS : DC.W 0
WEAPONS : DC.W 0
COLLISIONS : DC.W 0
LEVEL : DC.W 1
;------------------------------
START : DC.W 0
Y_MOUSE : DC.W 5 ;(entre 0 et 5)

OLD_Y : DC.W 0
colorsprite :
dc.w $000,$447,$669,$aad

red:
dc.w $080,$090,$0a0,$0b0,$0c0,$0d0,$0e0,$0f0
dc.w $0e0,$0d0,$0c0,$0b0,$0a0,$090,$080

tablelettres:
;lettres speciales
dc.l 1296,652,1294,1290,1296,1296,1296,1296,660,662,1296
dc.l 664,1292,658,1288,1296,668,670,672,674,676,678
dc.l 1280,1282,1284,1286,654,666,1296,1296,1296,656,1296
;lettres A-Z
dc.l 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38
dc.l 640,642,644,646,648,650
messon: DC.B ' ON'
messof: DC.B 'OFF'
message1: DC.B '                    '
message2: DC.B 'ENDLESS LIVES    OFF'
message3: DC.B 'ENDLESS ENERGY   OFF'
message4: DC.B 'WATER STOPPED    OFF' 
message5: DC.B 'START LEVEL       01'
message6: DC.B ' --  START GAME  -- '
tablelevels:
DC.B ' 00'
DC.B ' 01'
DC.B ' 02'
DC.B ' 03'
DC.B ' 04'
DC.B ' 05'
DC.B ' 06'
DC.B ' 07'
DC.B ' 08'
debuttexte:
DC.B 'INTRO 3 , CODED BY NINJA OF ANGELS !!'
DC.B ' GREETINGS TO ALL MEMBERS OF -ANGELS- ......'
fintexte:

even
bob: blk.b 12832,0
fonte : blk.b 2000,0
motif : blk.b 32,0
data: blk.b 9404,0
