0 Members and 2 Guests are viewing this topic.
call checkEOM ret z ld a,(numOptions) dec a sub (hl) ld b,a ;(numOptions-1)-curOption = número máximo de coordinadas que buscar ld a,(hl) ;cur option add a,a ;x2 por el tamaño de las coordinadas: 2 bytes por cada opción ld e,a ld d,0 ld hl,buttonCoords add hl,de ;añadir offset ld a,(hl) ;x value of current option ex af,af' ;guardar coordinada x en a' inc hl ld a,(hl) ;y value of current optionw2Down_loop: inc hl ;saltar valor x de la siguiente opción inc hl ;valor y cp (hl) ;compare current y coordinate to the next option until we reach an option on the next line or there are no more entries jr nz,w2Down_found djnz w2Down_loop ;repeat until no more entries left;si no hay más opciones debajo de nosotrxs, simplemente avanzar a la próxima opción ld hl,curOption inc (hl) retw2Down_found: dec hl ;retroceder a la coordinada x ex af,af' ;a = x value of curOption sub 4 ;ajustarlo un poco porque las coordinadas son guardadas unos 9 píxeles a la izquierda del texto jr nc,$+3 xor a ld b,a ;guardarlo ld c,$FF ;c = the nearest x value to our current x;basically repeat until the next value is further away from the current x than the previously checked value.; since we only check the line below, if one entry starts to get further away, all the rest of the entries on; that line must also get further awayw2D_f_loop: ld a,b ;recall x value sub (hl) ;subtract x value of the new coordinate jr nc,$+4 neg ;if it's negative, make it positive cp c ;check if it's closer or further away jr nc,w2D_update ;if it's further away than the previous coordinate, exit ld c,a ;otherwise, update c and continue inc hl inc hl jr w2D_f_loopw2D_update: ld de,buttonCoords+1 sbc hl,de ld a,l rra ;/2 ld (curOption),a retcheckEOM: ld a,(numOptions) dec a cp (hl) ;check if numOptions-1 = curOption (ie si quedan más opciones) ret
.db T_MENU,_p,_l,_a,_y,_e,_r,_1,T_MENU,_p,_l,_a,_y,_e,_r,_2.db T_NEWXY,11,10,T_MENU,_1,T_MENU,_2,T_MENU,_3,T_MENU,_4,T_MENU,_5,T_MENU,_6.db T_NEWXY,0,22,_O,_p,_t,_i,_o,_n,_s,_COLON.db T_NEWXY,0,30,T_MENU,_b,_u,_y,T_MENU,_s,_o,_m,_e,_t,_h,_i,_n,_g.db T_NEWXY,14,40,T_MENU,_p,_l,_a,_y,T_MENU,_q,_u,_i,_t.db T_NEWXY,10,50,T_MENU,_a,_t,_a,_c,_a,_r,T_NEWX,47,T_MENU,_e,_l,_e,_m,_e,_n,_t,_o.db T_NEWXY,10,56,T_MENU,_h,_a,_b,_i,_l,T_NEWX,47,T_MENU,_f,_u,_g,_a,_r,$FF