; Init le menu MENU_INIT: ; Remettre le booleen a vrai ld a,1 ld (menu_run), a ; Mettre une valeur de base pour la duree ld a,3 ld (duree_level), a ; De base pas de decalage ld a,0 ld (bool_decalage), a ld a,16 ld (modulo_liste), a ; Ecrire les vputs dans le buffer (pas de clignotement) set textWrite, (iy + sGrFlags) ret ; Afficher le menu MENU_PRINT: ; Effacer l'ecran call BUFCLR call FASTCOPY ; Par défaut il y aura des murs sauf si on force le contraire call MUR_INIT ; Afficher le focus call FOCUS_INIT ; Afficher les cases call CASE_PRINT ; Afficher les labels "easy" "medium" "hard" call DIFFICULTY_PRINT ; Afficher le label "press clear to quit" call HOWTO_QUIT_PRINT mp_loop: call MENU_SCAN_KEY call MENU_SCAN_ENTER ld a, (menu_run) or a jp nz, mp_loop ; boucler tant que le joueur n'a rien selectionne call MENU_IS_SELECTED call BUFCLR call FASTCOPY ; Lorsqu'on sort du menu, remettre le flag à son état normal res textWrite, (iy + sGrFlags) ret ; Executé lorsque l'on selectionne un level MENU_IS_SELECTED: ld a, (ycoord) sub 10 jp z, mis_easy sub 19 jp z, mis_medium sub 19 jp z, mis_hard ld b, 3 mis_easy: ld hl, level1 ld a, (xcoord) sub 32 ld b, 6 mis_loop0: sub 8 jp z, mis_fin ld de, 16 add hl, de djnz mis_loop0 mis_medium: ld hl, level7 ld a, (xcoord) sub 32 ld b, 6 mis_loop1: sub 8 jp z, mis_fin ld de, 18 add hl, de djnz mis_loop1 mis_hard: ld a, 1 ld (bool_decalage), a ld a, 20 ld (duree_level), a call MUR_DEL ; On vire les mur au bord pour les decalage c'est vraiment trop hard ld a, (xcoord) sub 40 jp z, mis_level13 sub 8 jp z, mis_level14 sub 8 jp z, mis_level15 sub 8 jp z, mis_level16 sub 8 jp z, mis_level17 sub 8 jp z, mis_level18 mis_level13: call MUR_INIT ld a, 0 ld (bool_decalage), a ld a, 16 ld (modulo_liste), a ld a, 3 ld (duree_level), a ld hl, level13 jp mis_fin mis_level14: ld a, 1 ld (bool_decalage), a ld hl, level14 jp mis_fin mis_level15: ld a, 1 ld (bool_decalage), a ld hl, level15 jp mis_fin mis_level16: call MUR_DEL ld a, 1 ld (bool_decalage), a ld hl, level16 jp mis_fin mis_level17: ld a, 1 ld (bool_decalage), a ld hl, level17 jp mis_fin mis_level18: call MUR_INIT ld a, 0 ld (bool_decalage), a ld a, 218 ld (modulo_liste), a ld a, 1 ld (duree_level), a ld hl, level1 jp mis_fin mis_fin: ld (pointeur_sur_liste), hl ret ; Si on fait un decalage, mettre bool_decalage a 1 bool_decalage: .db 0 ; Affichage de la difficulté DIFFICULTY_PRINT: ld b, 3 ld c,3 ld a, 10 ld hl, easy ; Au depart on affichera easy ld (diff), hl dp_boucle: ld l,c ld h,a ld (pencol),hl ld hl,(diff) call _vputs add a, 19 ld hl, (diff) ld de, 9 add hl,de ; Decalage pour afficher medium puis hard ld (diff), hl djnz dp_boucle ret ; Affichage du label "press clear to quit" HOWTO_QUIT_PRINT: ; afficher "clear to quit" ld a,56 ld (pencol),a ld a, 1 ld (penrow),a ld hl,clear_to_quit call _vputs ret clear_to_quit: .db "exit = clear",0 ; Afficher les cases CASE_PRINT: ld b, 3 ld de, 10 cp_categorie: push bc ld b, 6 ; 6 niveaux par categorie ld a, 40 cp_boucle: push bc push af push de ld hl, case call DRWSPR pop de pop af add a,8 pop bc djnz cp_boucle ld a, e add a, 19 ld e, a pop bc djnz cp_categorie call FASTCOPY call NUM_PRINT ret ; Afficher les numéros de level dans les cases NUM_PRINT: ld a,43 push af ld b, 6 ld hl, num ld (hl), 31h np_boucle: ld (pencol),a ;charge la valeur de la ligne de texte sur l'écran ld a,11 ld (penrow),a ;charge la valeur de la colone de texte. ld hl,num ;charge l'adresse du texte dans hl call _vputs ;appelle la rom call puts pop af add a, 8 push af ld hl, num ; changer le numero inc (hl) djnz np_boucle pop af ld a,43 push af ld b, 6 ld hl, num ld (hl), 31h np_boucle2: ld (pencol),a ;charge la valeur de la ligne de texte sur l'écran ld a,30 ld (penrow),a ;charge la valeur de la colone de texte. ld hl,num ;charge l'adresse du texte dans hl call _vputs ;appelle la rom call puts pop af add a, 8 push af ld hl, num ; changer le numero inc (hl) djnz np_boucle2 pop af ld a,43 push af ld b, 6 ld hl, num ld (hl), 31h np_boucle3: ld (pencol),a ;charge la valeur de la ligne de texte sur l'écran ld a,49 ld (penrow),a ;charge la valeur de la colone de texte. ld hl,num ;charge l'adresse du texte dans hl call _vputs ;appelle la rom call puts pop af add a, 8 push af ld hl, num ; changer le numero inc (hl) djnz np_boucle3 pop af ret ;; Scan key using direct input MENU_SCAN_KEY: ld a,$FF ; Before any action, reset the keyport out (1),a ; ...by sending to the port 1 the value 255 (FF ld a,$FE ; select the keyboard group to scan (here the arrow keys) out (1),a ; ...by sending to the keyboard port (1) the value FE. in a,(1) ; Get the port value, which says wich keys was pressed cp 254 ;\ jp z,msk_bot ;| cp 253 ;| Look for the key which was pressed and jump to the correct label. jp z,msk_left ;| cp 251 ;| jp z,msk_right ;| cp 247 ;| jp z,msk_top ;/ jp msk_finloop ; Callback depending on key pressed msk_top: ld a,(ycoord) sub 19 ld (ycoord),a jp msk_print msk_bot: ld a,(ycoord) add a,19 ld (ycoord),a jp msk_print msk_right: ld a,(xcoord) add a,8 ld (xcoord),a jp msk_print msk_left: ld a,(xcoord) sub 8 ld (xcoord),a jp msk_print ; Passe ici seulement si key press msk_print: ld a,(xcoord) ld e,(ycoord) call MENU_PROTECT_ARENA call FOCUS_PRINT msk_finloop: ret ; Lorsqu'on presse enter MENU_SCAN_ENTER: ld a,$FF ; Before any action, reset the keyport out (1),a ; ...by sending to the port 1 the value 255 (FF ld a,$FD ; select the keyboard group to scan (here the arrow keys) out (1),a ; ...by sending to the keyboard port (1) the value FE. in a,(1) ; Get the port value, which says wich keys was pressed cp 254 ;\ jp z, mse_pressed ;| cp 191 ;\ jp z, mse_clear_pressed ;| jp mse_finloop mse_pressed: ld a, 0 ld (menu_run), a jp mse_finloop mse_clear_pressed: pop af pop af jp fin_jeu mse_finloop: ret ; Savoir si on presse enter menu_run: .db 1 ; On affiche le curseur FOCUS_PRINT: ; effacer la tout le sprite (on l'affichera un pixel plus loin apres) ld a,(oldxcoord) ld de,(oldycoord) ld d,0 ld hl, focus call CLRSPR ; afficher nouveau sprite ld hl,(xcoord) ld de,(ycoord) ld (oldxcoord),hl ld (oldycoord),de ld a,l ld hl, focus call DRWSPR call FASTCOPY call CASE_PRINT call DIFFICULTY_PRINT call HOWTO_QUIT_PRINT ret ; Init the start position of the focus FOCUS_INIT: ; start at (16, 16) ld a, 40 ld (xcoord), a ld (oldxcoord), a ld a, 10 ld (ycoord), a ld (oldycoord), a ; print the focus call FOCUS_PRINT ret ; Cette routine permet d'eviter qu'on sorte de l'arene MENU_PROTECT_ARENA: ld a,(xcoord) cp 40 jp m, mpa_hors_arene cp 81 jp p, mpa_hors_arene ld a,(ycoord) cp 10 jp m, mpa_hors_arene cp 50 jp p, mpa_hors_arene jp place_valide mpa_hors_arene: ; Ici on restaure l'ancien placement (pour eviter la sortie d'arene) ld a, (oldxcoord) ld (xcoord), a ld a, (oldycoord) ld (ycoord), a mpa_place_valide: ret ; Une routine pour convertir entier vers texte serait mieux :) num: .db 31h,0 diff: .dw 0 easy: .db "easy ",$05, 0 medium: .db "medium ",$05, 0 hard: .db "hard ",$05, 0 ; Sprite du focus (utilise OR routines) focus: .db 00000000b .db 00000000b .db 00000000b .db 00000000b .db 01000000b .db 01100000b .db 01100000b .db 00000000b ; Les cases case: .db 11111111b .db 10000001b .db 10000001b .db 10000001b .db 10000001b .db 10000001b .db 10000001b .db 11111111b