+
+typedef struct {
+ SDL_Rect r;
+ int catnum;
+ mm_appref_t *ref;
+} ui_touch_t;
+#define MAXTOUCH 100
+ui_touch_t ui_touchrects [ MAXTOUCH ];
+unsigned char ui_touchrect_count = 0;
+
+void ui_register_reset ( void ) {
+ bzero ( ui_touchrects, sizeof(ui_touch_t)*MAXTOUCH );
+ ui_touchrect_count = 0;
+ return;
+}
+
+void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
+
+ if ( ui_touchrect_count == MAXTOUCH ) {
+ return;
+ }
+
+ ui_touchrects [ ui_touchrect_count ].r.x = x;
+ ui_touchrects [ ui_touchrect_count ].r.y = y;
+ ui_touchrects [ ui_touchrect_count ].r.w = w;
+ ui_touchrects [ ui_touchrect_count ].r.h = h;
+ ui_touchrects [ ui_touchrect_count ].catnum = catnum;
+ ui_touchrect_count++;
+
+ return;
+}
+
+void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
+
+ if ( ui_touchrect_count == MAXTOUCH ) {
+ return;
+ }
+
+ ui_touchrects [ ui_touchrect_count ].r.x = x;
+ ui_touchrects [ ui_touchrect_count ].r.y = y;
+ ui_touchrects [ ui_touchrect_count ].r.w = w;
+ ui_touchrects [ ui_touchrect_count ].r.h = h;
+ ui_touchrects [ ui_touchrect_count ].ref = app;
+ ui_touchrect_count++;
+
+ return;
+}
+
+void ui_touch_act ( unsigned int x, unsigned int y ) {
+
+ unsigned char i;
+ ui_touch_t *t;
+
+ for ( i = 0; i < ui_touchrect_count; i++ ) {
+ t = &(ui_touchrects [ i ]);
+
+ if ( x >= t -> r.x &&
+ x <= t -> r.x + t -> r.w &&
+ y >= t -> r.y &&
+ y <= t -> r.y + t -> r.h
+ )
+ {
+
+ if ( t -> ref ) {
+ ui_selected = t -> ref;
+ ui_push_exec();
+ } else {
+ ui_category = t -> catnum;
+ }
+
+ break;
+ }
+
+ } // for
+
+ return;
+}