The problem woth berber states and the muslims in general, is that there was a huge difficulty to keep legitimacy, for either the Marinids or the Hafsids to survive the 15th century, they would need to be what the almohads were : a regional power. For this you need things that maghreb is really lacking, like a pool of heathens whom you can heavily tax or ennemies that you can easily raid in order to get money to fund armies, or you do like Ahmed Addahbi and you go for a plan of production and exportations, thus you can get yourself a solid economical base upon wich you can start developping a country, as in the 14th century, numerical advantage was heavily against maghreb, what I can see, could be a Marinids concentrating themsemves since the second half of the 13th century on urbanizing Morocco and settling all the tribes, before coming up with a black "Janissaries", ending their reliance on their tribes, and beginnig by eating the Zianids Emirates, then slowly subduing the Hafsids. By 1400 the Maghreb would be united, assuming that they repel the portuguese, It gives them another 40 years of settling the tribes in Tunisia and central Maghreb, and thus by 1440 they are a power strong enough to keep the Granadans alive (an optimal scenario for me would be a Nasrid Emirates stretchibg from the Border with portugal anc closing castille from mediteranean sea, and gatting as far as Cordoba) this "ally" could give this Maghrebi state a foot in Europe, but I personally think that this Morocco would have much more to gain if it concentrated on subsaharian states, there is a lot of things to gain there, and with their iberian friends they could easily become colonizers when America is discorvered.