UINT32 ui_menu::ui_handler(running_machine &machine, render_container *container, UINT32 state) { /* if we have no menus stacked up, start with the main menu */ if (menu_stack == NULL) stack_push(auto_alloc_clear(machine, ui_menu_main(machine, container))); /* update the menu state */ if (menu_stack != NULL) menu_stack->do_handle(); /* clear up anything pending to be released */ clear_free_list(machine); /* if the menus are to be hidden, return a cancel here */ if ((ui_input_pressed(machine, IPT_UI_CONFIGURE) && !stack_has_special_main_menu()) || menu_stack == NULL) return UI_HANDLER_CANCEL; return 0; }
/* Called after reading the code heap from the image file, and after code GC. In the former case, we must add a large free block from compiling.base + size to compiling.limit. */ void heap::build_free_list(cell size) { heap_block *prev = NULL; clear_free_list(); size = (size + block_size_increment - 1) & ~(block_size_increment - 1); heap_block *scan = first_block(); free_heap_block *end = (free_heap_block *)(seg->start + size); /* Add all free blocks to the free list */ while(scan && scan < (heap_block *)end) { if(scan->type() == FREE_BLOCK_TYPE) add_to_free_list((free_heap_block *)scan); prev = scan; scan = next_block(scan); } /* If there is room at the end of the heap, add a free block. This branch is only taken after loading a new image, not after code GC */ if((cell)(end + 1) <= seg->end) { end->set_marked_p(false); end->set_type(FREE_BLOCK_TYPE); end->set_size(seg->end - (cell)end); /* add final free block */ add_to_free_list(end); } /* This branch is taken if the newly loaded image fits exactly, or after code GC */ else { /* even if there's no room at the end of the heap for a new free block, we might have to jigger it up by a few bytes in case prev + prev->size */ if(prev) prev->set_size(seg->end - (cell)prev); } }