/** * Allocate and map a single page, for a mono image. */ void dmd_alloc_low (void) { if (0) { dmd_pagenum_t page = dmd_alloc (); pinio_dmd_window_set (PINIO_DMD_WINDOW_0, page); pinio_dmd_window_set (PINIO_DMD_WINDOW_1, page); } dmd_alloc_pair (); }
/** * Do a DMD transition. * * Transitions are complicated because the old/new images may have * different color depths (mono or 4-color). Also, we can only map * two pages at a time, but there may be up to 4 different pages * involved. * * First, we check to see if both old and new images are mono. If so, * then the transition can be optimized slightly. * * For debugging transitions, define STEP_TRANSITION. The transition * will take place one frame at a time; use the launch button to * step through each frame. */ void dmd_do_transition (void) { const U8 new_dark_page = dmd_low_page; const U8 new_bright_page = dmd_high_page; dmd_trans_data_ptr = NULL; dmd_trans_data_ptr2 = NULL; page_push (TRANS_PAGE); if (dmd_transition->composite_init) { (*dmd_transition->composite_init) (); dmd_trans_data_ptr2 = dmd_trans_data_ptr; } while (dmd_in_transition) { #if defined(STEP_TRANSITION) && defined(MACHINE_LAUNCH_SWITCH) while (!switch_poll (MACHINE_LAUNCH_SWITCH)) task_sleep (TIME_33MS); task_sleep (TIME_100MS); while (switch_poll (MACHINE_LAUNCH_SWITCH)) task_sleep (TIME_33MS); #else task_sleep (dmd_transition->delay); #endif do { dmd_composite_page = dmd_alloc (); } while ((dmd_composite_page == (new_dark_page & ~1)) || (dmd_composite_page == (new_bright_page & ~1))); /* Handle the transition of the dark page first. * Use the lower composite pair page. */ pinio_dmd_window_set (PINIO_DMD_WINDOW_1, dmd_composite_page); dmd_do_transition_cycle (dmd_dark_page, new_dark_page); /* Handle the transition of the bright page. * Use the upper composite pair page (+1). */ { U8 *tmp_trans_data_ptr; tmp_trans_data_ptr = dmd_trans_data_ptr; dmd_trans_data_ptr = dmd_trans_data_ptr2; pinio_dmd_window_set (PINIO_DMD_WINDOW_1, dmd_composite_page+1); dmd_do_transition_cycle (dmd_bright_page, new_bright_page); dmd_trans_data_ptr2 = dmd_trans_data_ptr; dmd_trans_data_ptr = tmp_trans_data_ptr; } /* Make the composite pages visible */ dmd_dark_page = dmd_composite_page; dmd_bright_page = dmd_composite_page+1; } page_pop (); dmd_transition = NULL; }
/** * Allocate and map two different pages. */ void dmd_alloc_pair (void) { wpc_dmd_set_low_page (dmd_alloc ()); wpc_dmd_set_high_page (wpc_dmd_get_low_page () + 1); }
/** * Allocate and map two different, consecutive pages. */ void dmd_alloc_pair (void) { dmd_pagenum_t page = dmd_alloc (); dmd_map_low_high (page); }
/** Allocate and map a single page, into the 'high' region. */ void dmd_alloc_high (void) { wpc_dmd_set_high_page (dmd_alloc ()); }