;******************************************************************************** ; ; ; ; ; CASTLEVANIA, prelude of chaos ; ; ; ; ; ; v 1.0 ; ; programmed by Martin Bousquet (martin.bousquet@hotmail.fr) ; ; for TI-82 (with Crash shell) ; ; published in September 2007 ; ; ; ; ;******************************************************************************** #include "crash82.inc" #define push_all push af \ push bc \ push de \ push hl \ push ix #define pop_all pop ix \ pop hl \ pop de \ pop bc \ pop af keypressed =TEXT_MEM temp5 =keypressed+1 temp4 =temp5+2 key2 =temp4+1 timer =key2+1 ;;;;; tiles num_contexte =60 num_blocs2 =num_contexte+4 ;;;;;; constantes arme_phase2 =10 arme_finphase =15 nbre_spriteamis =8 nbre_arme2 =7 spritemax =11 ;;;;; variables pointeur_carte =timer+1 pointeur_table =pointeur_carte+2 num_fouet =pointeur_table+2 num_arme =num_fouet+1 num_arme2 =num_arme+1 fouetx =num_arme2+1 fouetlongueur =fouetx+1 fouetimg =fouetlongueur+1 sprite_var =fouetimg+2 spriteid =sprite_var spritetype =spriteid+2 spriteloc =spritetype+1 spritestat =spriteloc+2 spritestat2 =spritestat+1 spritevie =spritestat2+1 spritetype16 =spritevie+1 energie =spritetype16+2 energiemax =energie+1 coeur =energiemax+1 vies =coeur+1 sp_0 =vies+1 prix =sp_0+2 adr_txt =prix+1 adr_fintxt =adr_txt+2 arme2num =adr_fintxt+2 arme2loc =arme2num+1 arme2img =arme2loc+2 arme2stat =arme2img+2 arme2stat2 =arme2stat+1 arme2IA =arme2stat2+1 arme2largeur =arme2IA+2 arme2dommages =arme2largeur+1 equipement =arme2dommages+1 bossflag =equipement+1 marais_flag =bossflag+1 cheat_flag =marais_flag+1 GBA_VAR =cheat_flag+2 map_width =GBA_VAR ;2 octets map_height =GBA_VAR+2 ;2 octets scroll_y =GBA_VAR+4 ;2 octets scroll_x =GBA_VAR+6 ;2 octets mask_y =GBA_VAR+8 ;1 octet mask_x =GBA_VAR+9 ;1 octet mask_x2 =GBA_VAR+10 ;1 octet temp =GBA_VAR+11 ;1 octet temp2 =GBA_VAR+12 ;1 octet temp3 =GBA_VAR+13 ;1 octet Sprite_Img =temp3+1 ; 32 octets .org START_ADDR .db "Castlevania",0 ;******************************* INITIALISATION ********************************* set 3,(iy+$05) ; write white on black push af ld (sp_0),sp pop af ld hl,Txt_nouveau ld (temp5),hl Ecran_principal: ld bc,0 ld (cheat_flag),bc ld hl,GRAPH_MEM+592 Menu: ld (temp4),hl ld hl,Titre ld de,GRAPH_MEM ld bc,12*54 ldir ld h,d ld l,e inc de ld (hl),%11111111 ld bc,12*10-1 ldir ld hl,(temp4) call Afficher_Curseur call CR_GRBCopy ld bc,$3028 ld (GRAF_CURS),bc ld hl,(temp5) call D_ZM_STR2 ld b,54 ld (GRAF_CURS),bc call D_ZM_STR2 ld a,(cheat_flag+1) or a jr z,Menu_boucle ld bc,$3901 ld (GRAF_CURS),bc ld hl,Cheat_txt call D_ZM_STR2 Menu_boucle: call GET_KEY or a jr z,Menu_suite4 push hl ld hl,Cheat_table ld de,(cheat_flag) add hl,de inc de cp (hl) pop hl jr z,Menu_suite3 ld e,0 Menu_suite3: ld (cheat_flag),de ld b,a ld a,7 cp e ld a,b jr nz,Menu_suite4 inc d ld (cheat_flag),de ld hl,GRAPH_MEM+592 jr Menu Menu_suite4: cp G_CLEAR ret z cp G_UP jr nz,Menu_suite ld hl,GRAPH_MEM+592 jp Menu Menu_suite: cp G_DOWN jr nz,Menu_suite2 ld hl,GRAPH_MEM+664 jp Menu Menu_suite2: cp G_ENTER jr nz,Menu_boucle ld hl,(temp4) ld de,GRAPH_MEM+664 sbc hl,de jr z,Choix2 ld hl,(temp5) ld de,Txt_nouveau or a sbc hl,de jr nz,Reprendre_jeu ld hl,Sauvegarde ld de,Init_sauvegarde ld b,7 Verif_partievide: ; check if there is a saving ld a,(de) cp (hl) jr nz,Partie_nonvide inc de inc hl djnz Verif_partievide call Nouveau_jeu ld hl,Txt_nouveau ld (temp5),hl jp Ecran_principal Reprendre_jeu: ; Load the game ld hl,Sauvegarde ld a,(hl) inc hl ld (equipement),a ld a,(hl) inc hl ld (num_fouet),a ld e,(hl) inc hl ld d,(hl) inc hl ld (pointeur_carte),de ld a,(hl) inc hl ld (energiemax),a ld a,(hl) inc hl ld (bossflag),a ld a,(hl) ld (coeur),a call NP_suite ld hl,Txt_nouveau ld (temp5),hl jp Ecran_principal Choix2: ld hl,(temp5) ld de,Txt_nouveau sbc hl,de ld hl,Continuer_txt ld (temp5),hl jp z,Ecran_principal Effacer_jeu: ; Clear the saving ld hl,Init_sauvegarde ld de,Sauvegarde ld bc,7 ldir call Battement ld hl,Txt_nouveau ld (temp5),hl jp Ecran_principal Partie_nonvide: res 3,(iy+$05) ROM_CALL(CLEARLCD) ld bc,$0002 ld (CURSOR_POS),bc ld de,Txt_partienonvide call D_ZT_STR2 call Pause set 3,(iy+$05) jp Ecran_principal ;***************************** NOUVEAU JEU ***************************** Nouveau_jeu: ; New game ld hl,Aljiba_table1 ld (pointeur_carte),hl ld a,24 ld (energiemax),a xor a ld (equipement),a ld (num_fouet),a ld (bossflag),a ld a,50 ld (coeur),a jr NP_suite Nouvelle_partie: ld a,5 ld (coeur),a NP_suite: xor a ld (num_arme2),a ld a,$c9 ld (Cristal_flag),a ld a,9 ld (vies),a Nouvelle_vie: ; New life call Battement ld hl,GRAPH_MEM ld de,GRAPH_MEM+1 ld bc,767 ld (hl),%11111111 ldir call CR_GRBCopy ld bc,$1c20 ld (GRAF_CURS),bc ld hl,Player_txt call D_ZM_STR2 ld a,(vies) add a,48 ROM_CALL(M_CHARPUT) call Pause ld a,(energiemax) ld (energie),a call Afficher_barredevie call Actualiser_nbrecoeur xor a ld (persostat),a ld (arme2num),a ;******************************* NOUVELLE CARTE ********************************* Nouvelle_carte: ; New map call Battement ld hl,(pointeur_carte) ld b,0 ld c,(hl) inc hl ld (scroll_y),bc ld c,(hl) inc hl ld (scroll_x),bc ld a,(hl) and %11100000 srl a \ srl a ld c,a ld a,(hl) and %00011111 add a,a add a,a add a,a ld b,a ld (persoloc),bc inc hl ld e,(hl) inc hl ld d,(hl) ex de,hl ld d,0 ld e,(hl) inc hl ld (map_height),de ld e,(hl) inc hl ld (map_width),de push hl pop ix call Decompression_carte ld (pointeur_table),ix call gba_initsprite ld hl,0 ld de,(map_height) ld bc,(map_width) call gba_hl_plus_dexbc ld b,h ld c,l ld hl,Carte_addr Restaurer_blocdepierre: ; restore broken stones ld a,14 cp (hl) jr nz,Restaurer_blocdepierre_suite dec (hl) Restaurer_blocdepierre_suite: inc hl dec bc ld a,b or c jr nz,Restaurer_blocdepierre ld a,1 ld (perso_id),a call gba_initmap ;*************************** BOUCLE PRINCIPALE ****************************** Boucle_principale: ; Main Loop call KEYPRESSED ld hl,timer inc (hl) call copier_APDGM ld bc,BP_suite push bc ld a,(persostat) bit 2,a jp nz,Perso_saut bit 3,a jp z,Perso_normal ret BP_suite: call Gestion_Scrollgd call Gestion_Scrollhb ld hl,persostat bit 3,(hl) call nz,Perso_arme call Perso_collision_speciale call Gestion_arme2 call Gestion_sprites call Afficher_Perso call CR_GRBCopy call Afficher_nbrecoeur ld a,(keypressed) bit 7,a jr nz,Boucle_principale ld hl,GRAPH_MEM+570 ld (temp4),hl Choix_arme2: ; Choose auxiliary weapon call Dessin_cadre ld de,flecheg_img ld hl,GRAPH_MEM+589 ld bc,1*256+7 call Affimage_boucle ld hl,GRAPH_MEM+590 ld bc,1*256+7 call Affimage_boucle ld hl,(temp4) ld de,Curseur_Img ld bc,1*256+5 call Affimage_boucle Afficher_arme2pic: ld a,(num_arme2) add a,a add a,a add a,a ld hl,arme2_pic ld d,0 ld e,a add hl,de ex de,hl ld hl,GRAPH_MEM+591 ld bc,1*256+8 call Affimage_boucle call CR_GRBCopy ld bc,$2e38 ld (GRAF_CURS),bc ld hl,Txt_continuer call D_ZM_STR2 ld b,52 ld (GRAF_CURS),bc call D_ZM_STR2 Choix_arme2_boucle: call GET_KEY cp G_LEFT jr z,Choix_arme2_inc cp G_RIGHT jr z,Choix_arme2_dec cp G_UP jr nz,Choix_arme2_suite ld hl,GRAPH_MEM+570 ld (temp4),hl jr Choix_arme2 Choix_arme2_suite: cp G_DOWN jr nz,Choix_arme2_suite2 ld hl,GRAPH_MEM+642 ld (temp4),hl jr Choix_arme2 Choix_arme2_suite2: cp G_ENTER jr nz,Choix_arme2_boucle call Afficher_barredevie ld hl,(temp4) ld de,GRAPH_MEM+570 or a sbc hl,de jr nz,Sauver_jeu ld hl,Cristal_flag ld (hl),$c9 ld a,(num_arme2) or a jp z,Boucle_principale cp 3 jp nc,Boucle_principale dec (hl) jp Boucle_principale Sauver_jeu: ; Save the game ld hl,Sauvegarde ld a,(equipement) ld (hl),a inc hl ld a,(num_fouet) ld (hl),a inc hl ld de,(pointeur_carte) ld (hl),e inc hl ld (hl),d inc hl ld a,(energiemax) ld (hl),a inc hl ld a,(bossflag) ld (hl),a inc hl ld a,(coeur) ld (hl),a ret Choix_arme2_inc: ld a,(num_arme2) Choixarme2inc_boucle: inc a call Verif_equipement jr c,Choixarme2inc_boucle ld (num_arme2),a jp Afficher_arme2pic Choix_arme2_dec: ld a,(num_arme2) Choixarme2dec_boucle: dec a call Verif_equipement jr c,Choixarme2dec_boucle ld (num_arme2),a jp Afficher_arme2pic Verif_equipement: ; Check equipement or a ret z cp 255 jr nz,verifequ_suite ld a,nbre_arme2 verifequ_suite: cp nbre_arme2+1 jr nz,verifequ_suite2 xor a ret verifequ_suite2: ld b,a push bc ld a,(equipement) verifequ_boucle: add a,a djnz verifequ_boucle pop bc ld a,b ccf ret ;************************** ROUTINES D'AFFICHAGE **************************** Afficher_Perso: ; Draw main caracter ld a,(persostat) and %11110000 jr z,Affperso_suite ld a,(timer) and %1000 ret nz ld a,(timer) and %11 jr nz,Affperso_suite ld a,(persostat) add a,%00010000 ld (persostat),a Affperso_suite: ld hl,table_persobustes ld de,table_persojambes ld a,(persostat) and %1111 ld c,a ld b,0 add hl,bc ex de,hl add hl,bc ld c,(hl) ld b,0 ld hl,Img_persojambes ld a,(cheat_flag+1) or a jr z,Affperso_normal push de ld de,192 add hl,de pop de Affperso_normal: add hl,bc ex de,hl ld c,(hl) ld b,0 ld hl,Img_persobustes ld a,(cheat_flag+1) or a jr z,Affperso_normal2 push de ld de,192 add hl,de pop de Affperso_normal2: push de ld a,(arme_compteur) cp arme_phase2 jr c,AP_suite ld de,36 sbc hl,de AP_suite: add hl,bc ld de,Sprite_Img ld bc,18 ldir pop hl ld bc,14 ldir ld hl,Sprite_Img ld bc,(persoloc) ld de,$0110 call gba_drawsprite ld a,(persostat) ; Using a whip? bit 3,a ret z ld a,(num_arme) or a ret nz ld a,(arme_compteur) cp arme_phase2 jr nc,Aff_fouet ld hl,Fouet_img0 ld bc,(persoloc) ld a,(cheat_flag+1) or a ld a,4 jr z,Fouet0_suite ld a,10 Fouet0_suite: add a,c ld c,a ld a,-8 add a,b ld b,a ld a,(persostat) bit 1,a jr z,Fouet_suite ld de,20 add hl,de ld a,16 add a,b ld b,a Fouet_suite: ld de,$010a call gba_drawsprite ret Aff_fouet: ; Draw whip ld a,(fouetx) ld hl,persox add a,(hl) ld b,a ld a,(cheat_flag+1) or a ld a,(persoy) jr z,Afffouet_suite2 add a,6 Afffouet_suite2: add a,4 ld c,a ld hl,(fouetimg) ld a,(num_fouet) cp 4 jr nz,Afffouet_suite ld a,(timer) and %10 jr nz,Afffouet_suite ld de,18 add hl,de Afffouet_suite: ld de,(fouetlongueur-1) ld e,3 call gba_drawsprite ret Dessin_cadre: ld de,GRAPH_MEM+480 ld hl,Cadre_Img ld bc,24 ldir ex de,hl push hl ld (hl),%10111111 inc hl ld (hl),%11111111 ld d,h ld e,l inc de ld bc,10 ldir ld (hl),%11111101 pop hl ld bc,12*20 ldir ex de,hl ld hl,Cadre_Img+12 ld bc,24 ldir ret Afficher_Curseur: ; Draw cursor ld de,Curseur_Img ld bc,1*256+5 Affimage_boucle: push bc push hl Affimage_boucle2: ld a,(de) inc de ld (hl),a inc hl djnz Affimage_boucle2 pop hl ld bc,12 add hl,bc pop bc dec c jr nz,Affimage_boucle ret Afficher_barredevie: ld hl,GRAPH_MEM+672 ld de,GRAPH_MEM+673 ld bc,11 ld (hl),%11111111 ldir inc hl inc de ld (hl),%00000000 ld bc,71 ldir inc hl inc de ld (hl),%11111111 ld bc,11 ldir ld hl,GRAPH_MEM+696 ld de,Barredevie_img1 ld bc,1*256+4 call Affimage_boucle ld a,(energiemax) srl a srl a srl a push af ld d,0 ld e,a ld hl,GRAPH_MEM+697 add hl,de ld de,Barredevie_img2 ld bc,1*256+4 call Affimage_boucle ld a,(energie) dec a ld hl,GRAPH_MEM+709 Affvie_boucle: ld (hl),255 inc hl sub 8 jr nc,Affvie_boucle cpl dec hl Affvie_boucle2: or a jr z,Affvie_fin sla (hl) dec a jr Affvie_boucle2 Affvie_fin: ld hl,GRAPH_MEM+709 ld de,GRAPH_MEM+721 pop af ld b,0 ld c,a ldir ld de,Coeur_img2 ld bc,1*256+5 ld hl,GRAPH_MEM+705 call Affimage_boucle ret Actualiser_nbrecoeur: ; update hearts ld de,Coeur_str+2 ld hl,(coeur) ld h,0 call UNPACK_HL add a,48 ld (de),a dec de call UNPACK_HL add a,48 ld (de),a dec de call UNPACK_HL add a,48 ld (de),a ret Afficher_nbrecoeur: ; put numbers of hearts set 7,(iy+$14) ;always write to screen res 3,(iy+$05) ld hl,Coeur_str ld bc,57*256+80 ld (GRAF_CURS),bc ROM_CALL(D_ZM_STR) set 3,(iy+$05) res 7,(iy+$14) ret Coeur_str: ; Hearts string .db 0,0,0,0 ;************************** COLLISION ********************************* Bloc_type1: ; used for left and right collision cp 1 ret z cp 3 ret z cp 4 ret z cp 13 ret Bloc_type2: ; used for down collision cp 1 ret z cp 3 ret z cp 4 ret z cp 5 ret z cp 43 ret z cp 49 ret z cp 13 Cristal_flag: ret z ; $c9: ret $c8: ret z cp 225 ret Bloc_type3: ; used for up collision cp 1 ret z cp 3 ret z cp 4 ret z cp 13 ret Bloc_type4: ; used for holy water collision cp 1 ret z cp 2 ret z cp 3 ret z cp 4 ret z cp 5 ret z cp 225 ret Sprite_collision_bas: ; down collision ld a,16 add a,c ld c,a ld a,(mask_y) add a,c and %111 ret nz push bc call gba_collision call Bloc_type2 pop bc ret z ld a,7 add a,b ld b,a call gba_collision call Bloc_type2 ret Sprite_collision_droite: ; right collision ld a,8 add a,b ld b,a ld a,(mask_x2) add a,b and %111 ret nz push bc call gba_collision call Bloc_type1 pop bc ret z ld a,7 add a,c ld c,a push bc call gba_collision call Bloc_type1 pop bc ret z ld a,8 add a,c ld c,a call gba_collision call Bloc_type1 ret Sprite_collision_gauche: ; left collision ld a,(mask_x2) add a,b and %111 ret nz dec b push bc call gba_collision call Bloc_type1 pop bc ret z ld a,7 add a,c ld c,a push bc call gba_collision call Bloc_type1 pop bc ret z ld a,8 add a,c ld c,a call gba_collision call Bloc_type1 ret Sprite_collision_haut: ; up collision ld a,c bit 7,a ret nz ld a,(mask_y) add a,c inc a and %111 ret nz push bc call gba_collision call Bloc_type3 pop bc ret z ld a,7 add a,b ld b,a call gba_collision call Bloc_type3 ret Perso_collision_speciale: ; special collision (water, swamp...) ld bc,(persoloc) ld a,12 add a,c ld c,a bit 7,c ret nz inc b \ inc b \ inc b bit 7,c ret nz call gba_collision cp 2 jp z,Perso_mort cp 33 ; pic jr nz,PCS_suite2 ld a,(persostat) and %11110000 ret nz ld a,(energie) sub 3 ld (energie),a jp c,Perso_mort jp z,Perso_mort call Afficher_barredevie ld hl,persostat set 4,(hl) ld a,%10 bit 1,(hl) jp nz,Perso_initsaut ld a,%100 jp Perso_initsaut PCS_suite2: ld hl,marais_flag ; swamp flag ld (hl),0 cp 56 jr nz,PCS_suite inc (hl) ret PCS_suite: cp num_blocs2 ; 64 ret c cp num_blocs2+4 ; 68 ret nc ld hl,(pointeur_table) sub num_blocs2 ld d,0 ld e,a add hl,de add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl cp 3 push hl ret nc ld (pointeur_carte),hl pop bc pop bc jp Nouvelle_carte Perso_collision_speciale2: ; second special collsion (open doors...) ld bc,(persoloc) bit 7,c ret nz inc b \ inc b \ inc b bit 7,c ret nz call gba_collision cp num_contexte ret c cp num_blocs2 ret nc ld hl,(pointeur_table) ld de,18 add hl,de sub num_contexte add a,a ld d,0 ld e,a add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl ld (pointeur_carte),hl ld sp,(sp_0) jp Nouvelle_carte Collision_sprite_rectangle: ld a,(spriteloc) sub c cp l jr c,CSR_suite neg cp e ret nc CSR_suite: ld a,(spriteloc+1) sub b cp h ret c neg cp d ret ;*********************************** TEXTES ********************************** Parler_sprite: ; talk to people ld l,(hl) ld h,0 ld de,(pointeur_table) add hl,de ld de,8 add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl ld de,Pas_question_txt call CP_HL_DE jr nc,Texte_normal Question: ld a,(hl) ld (prix),a inc hl ld (adr_txt),hl ld de,GRAPH_MEM+673 call Aff_question Question_boucle: call GET_KEY cp G_LEFT jr nz,Question_suite ld de,GRAPH_MEM+673 call Aff_question Question_suite: cp G_RIGHT jr nz,Question_suite2 ld de,GRAPH_MEM+675 call Aff_question Question_suite2: cp G_ENTER jr nz,Question_boucle ld hl,GRAPH_MEM+673 sbc hl,de jp z,Afficher_barredevie ld a,(coeur) ld hl,prix sub (hl) jr nc,Vendu ld hl,Tropcher_txt jr Texte_normal Vendu: ; sold ld (coeur),a push hl call Actualiser_nbrecoeur call Afficher_barredevie pop de ld hl,(adr_fintxt) push hl ret Already_one: ld a,(coeur) ex de,hl add a,(hl) ld (coeur),a ld hl,Alreadyone_txt call Texte_normal call Actualiser_nbrecoeur jp Afficher_barredevie Texte_normal: ; normal text call Afficher_texte call Pause call Afficher_barredevie ret Aff_question: ; put question push de push de call Dessin_cadre pop hl ld de,Curseur_Img ld bc,1*256+5 call Affimage_boucle call CR_GRBCopy ld hl,(adr_txt) call Afficher_texte2 inc hl ld (adr_fintxt),hl ld bc,$370e ld (GRAF_CURS),bc ld hl,YesNo_txt call D_ZM_STR2 ld a,(CURSOR_X) add a,6 ld (CURSOR_X),a call D_ZM_STR2 pop de ret Lire_panneau: ; read the board ld hl,(pointeur_table) ld de,26 add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl call Afficher_texte call Pause call Afficher_barredevie ret Afficher_texte: ; put text push hl call Dessin_cadre call CR_GRBCopy pop hl Afficher_texte2: ld bc,$2a03 ld (GRAF_CURS),bc Afftxt_boucle: call D_ZM_STR2 xor a cp (hl) ret z ld a,3 ld (CURSOR_X),a ld a,(CURSOR_Y) add a,6 ld (CURSOR_Y),a jr Afftxt_boucle ret Scroll_txt: ; used at the end of the game push hl ld de,APD_BUF ld hl,GRAPH_MEM ld bc,768 ldir pop hl set 7,(iy+$14) ld b,58 Scrolltxt_boucle: push hl push bc ld hl,APD_BUF ld de,GRAPH_MEM ld bc,768 ldir pop bc pop hl push bc push hl Scrolltxt_boucle2: push bc ld a,58 cp b jr c,Texte_clip ld c,4 ld (GRAF_CURS),bc call D_ZM_STR2 jr Scrolltxt_suite Texte_clip: ld a,(hl) inc hl cp %00100000 jr z,Scrolltxt_suite and %1111 cp %0010 jr nz,Texte_clip Scrolltxt_suite: pop bc ld a,6 add a,b ld b,a xor a cp (hl) jr nz,Scrolltxt_boucle2 push bc call CR_GRBCopy call Battement2 pop bc ld a,255 cp b pop hl pop bc push af dec b pop af jr nz,Scrolltxt_boucle res 7,(iy+$14) ret Decompression_txt: dec de ld hl,Texte_addr ld c,%00001111 Decompressiontxt_boucle: push hl ld hl,Table_decompression_txt Dec_plusieursnibble: call Decompression_nibblesuivant push de ld d,0 ld e,a add hl,de pop de cp %1111 jr z,Dec_plusieursnibble ld a,(hl) pop hl ld (hl),a inc hl or a jr nz,Decompressiontxt_boucle ret Decompression_nibblesuivant: srl c \ srl c srl c \ srl c jr nc,Decnibble_suite ld c,%11110000 inc de ld a,(de) and c srl a \ srl a srl a \ srl a ret Decnibble_suite: ld a,(de) and c ret D_ZM_STR2: push bc ex de,hl call Decompression_txt ex de,hl inc hl push hl ld hl,Texte_addr ROM_CALL(D_ZM_STR) pop hl pop bc ret D_ZT_STR2: call Decompression_txt ld hl,Texte_addr ROM_CALL(D_ZT_STR) ret ;***************************** ROUTINES DIVERSES ***************************** Decompression_carte: ; decompress the map ld c,(ix) ld b,0 inc ix push ix add ix,bc pop de ld hl,Carte_addr inc b \ inc c Decompression_boucle: ld (hl),0 call Decompression_bitsuivant add a,a jr nc,Decompression_suite inc (hl) call Decompression_bitsuivant add a,a jr nc,Decompression_suite push af ld a,(ix) inc ix ld (hl),a pop af Decompression_suite: inc hl jr Decompression_boucle Decompression_bitsuivant: dec b ret nz ld b,8 ld a,(de) inc de dec c ret nz pop hl ret Battement: ROM_CALL(CLEARLCD) Battement2: ld b,25 Ecranblanc_boucle: halt djnz Ecranblanc_boucle ret Tremble: ld b,30 Tremble_boucle2: push bc call copier_APDGM call CR_GRBCopy call gba_scroll_up ld bc,336 ld hl,APD_BUF ld de,GRAPH_MEM Tremble_boucle1: ld a,(hl) inc hl inc hl ld (de),a inc de inc de dec bc ld a,b or c jr nz,Tremble_boucle1 call CR_GRBCopy call gba_scroll_down pop bc djnz Tremble_boucle2 ret copier_APDGM: ld hl,APD_BUF ld de,GRAPH_MEM ld bc,672 ldir ret Pause: call GET_KEY cp G_ENTER jr nz,Pause ret KEYPRESSED: ld a,(keypressed) ld c,a ld b,255 ld a,%11111110 out (1),a in a,(1) bit 1,a jr nz,Pas_gauche res 1,b Pas_gauche: bit 2,a jr nz,Pas_droite res 2,b Pas_droite: bit 3,a jr nz,Pas_haut res 3,b Pas_haut: bit 0,a jr nz,Pas_bas res 4,b Pas_bas: ld a,%11111101 out (1),a in a,(1) bit 6,a jr nz,Pas_clear res 7,b Pas_clear: ld a,%10111111 out (1),a in a,(1) bit 5,a jr nz,Pas_2nd res 0,b Pas_2nd: ld a,%11011111 out (1),a in a,(1) bit 7,a jr nz,Pas_alpha res 5,b Pas_alpha: ld a,b ld (keypressed),a xor c and c cpl ld (key2),a ret ;**************************** FICHIERS INCLUDES ***************************** #include "gba.inc" #include "sprites.inc" #include "IA.inc" #include "perso.inc" #include "armes.inc" #include "textes.inc" #include "images.inc" #include "tableaux.inc" #include "cartes.inc" .end