From: sparky4 Date: Fri, 3 Nov 2017 19:57:39 +0000 (-0500) Subject: notime X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=48a59b737b260f4ae17210137c19486d1cc42eb3 notime --- diff --git a/OUT.ANI b/OUT.ANI new file mode 100755 index 00000000..e69de29b diff --git a/src/.xcroll.c.kate-swp b/src/.xcroll.c.kate-swp new file mode 100755 index 00000000..9b3a8b2a Binary files /dev/null and b/src/.xcroll.c.kate-swp differ diff --git a/src/lib/doslib b/src/lib/doslib index 3801d6b6..9f68b899 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit 3801d6b6128ef21c0fdbbdd407dd6ff818b0c1c7 +Subproject commit 9f68b899de82e9ed49cf03bd617820f98db034c3 diff --git a/src/lib/ll.c b/src/lib/ll.c index afb69f3f..55aa90af 100755 --- a/src/lib/ll.c +++ b/src/lib/ll.c @@ -1,12 +1,27 @@ #include "src/lib/ll.h" +#ifdef OTHERMERGELISTSTIFF +int listLength(node_t * item) +{ + node_t * cur = item; + int size = 0; + + while (cur->next != NULL) + { + ++size; + cur = cur->next; + } + + return size; +} + void print_list(node_t * head) { node_t * current = head; - while (current != NULL) + while (current->next != NULL) { - printf("[%u] %d\n", current->id, current->val); + printf("[%u]= %d\n", current->id, current->val); current = current->next; } } @@ -109,3 +124,168 @@ int remove_by_index(node_t ** head, int n) return retval; } +#else +/* Takes two lists sorted in increasing order, and splices + their nodes together to make one big sorted list which + is returned. */ +struct node* SortedMerge(struct node* a, struct node* b) +{ + /* a dummy first node to hang the result on */ + struct node dummy; + + /* tail points to the last result node */ + struct node* tail = &dummy; + + /* so tail->next is the place to add new nodes + to the result. */ + dummy.next = NULL; + while (1) + { + if (a == NULL) + { + /* if either list runs out, use the + other list */ + tail->next = b; + break; + } + else if (b == NULL) + { + tail->next = a; + break; + } + if (a->data <= b->data) + Movenode(&(tail->next), &a); + else + Movenode(&(tail->next), &b); + + tail = tail->next; + } + return(dummy.next); +} + +struct node* LL_merge(struct node* a, struct node* b) +{ + /* a dummy first node to hang the result on */ + struct node dummy; + + /* tail points to the last result node */ + struct node* tail = &dummy; + + /* so tail->next is the place to add new nodes + to the result. */ + dummy.next = NULL; + Movenode(&(tail->next), &a); + a = a->next; + tail = tail->next; + while (1) + { + if (a == NULL) + { + /* if either list runs out, use the + other list */ + tail->next = b; + break; + } + else if (b == NULL) + { + tail->next = a; + break; + } + if (a->data <= b->data) + Movenode(&(tail->next), &a); + else + Movenode(&(tail->next), &b); + + tail = tail->next; + } + return(dummy.next); +} + +/* The function removes duplicates from a sorted list */ +void removeDuplicates(struct node* head) +{ + /* Pointer to traverse the linked list */ + struct node* current = head; + + /* Pointer to store the next pointer of a node to be deleted*/ + struct node* next_next; + + /* do nothing if the list is empty */ + if (current == NULL) + return; + + /* Traverse the list till last node */ + while (current->next != NULL) + { + /* Compare current node with next node */ + if (current->data == current->next->data) + { + /* The sequence of steps is important */ + next_next = current->next->next; + free(current->next); + current->next = next_next; + } + else /* This is tricky: only advance if no deletion */ + { + current = current->next; + } + } +} + +/* UTILITY FUNCTIONS */ +/* Movenode() function takes the node from the front of the + source, and move it to the front of the dest. + It is an error to call this with the source list empty. + + Before calling Movenode(): + source == {1, 2, 3} + dest == {1, 2, 3} + + Affter calling Movenode(): + source == {2, 3} + dest == {1, 1, 2, 3} */ +void Movenode(struct node** destRef, struct node** sourceRef) +{ + /* the front source node */ + struct node* newnode = *sourceRef; + assert(newnode != NULL); + + /* Advance the source pointer */ + *sourceRef = newnode->next; + + /* Link the old dest off the new node */ + newnode->next = *destRef; + + /* Move dest to point to the new node */ + *destRef = newnode; +} +#endif + +/* Function to insert a node at the beginging of the + linked list */ +void pushll(struct node** head_ref, int new_data) +{ + /* allocate node */ + struct node* new_node = + (struct node*) malloc(sizeof(struct node)); + + /* put in the data */ + new_node->data = new_data; + + /* link the old list off the new node */ + new_node->next = (*head_ref); + + /* move the head to point to the new node */ + (*head_ref) = new_node; +} + +/* Function to print nodes in a given linked list */ +void printList(struct node *node) +{ + while (node!=NULL) + { + printf("%d ", node->data); + node = node->next; + } +} +#endif diff --git a/src/lib/ll.h b/src/lib/ll.h index f653825f..159aa4ca 100755 --- a/src/lib/ll.h +++ b/src/lib/ll.h @@ -1,22 +1,38 @@ #ifndef __LL_H__ #define __LL_H__ #include +#include +#include #include "src/lib/16_tail.h" +//#define OTHERMERGELISTSTIFF + +/* Link list node_t */ typedef struct node { struct node *prev; rgb_t d; - int val; + int data; struct node *next; word id; } node_t; +#ifdef OTHERMERGELISTSTIFF +int listLength(node_t * item); void print_list(node_t * head); void pushe(node_t * head, int val); void pushs(node_t ** head, int val); int pop(node_t ** head); int remove_last(node_t * head); int remove_by_index(node_t ** head, int n); +#else +/* pull off the front node of the source and put it in dest */ +void Movenode(struct node** destRef, struct node** sourceRef); +struct node* SortedMerge(struct node* a, struct node* b); +struct node* LL_merge(struct node* a, struct node* b); +void pushll(struct node** head_ref, int new_data); +void printList(struct node *node); +void removeDuplicates(struct node* head); +#endif #endif diff --git a/src/palllist.c b/src/palllist.c index eb428c1d..daab2b38 100755 --- a/src/palllist.c +++ b/src/palllist.c @@ -59,37 +59,125 @@ */ #include "src/lib/ll.h" +#if 0 +//def OTHERMERGELISTSTIFF + void main(int argc, char *argv[]) { int i; - node_t * head = NULL; node_t * heao = NULL; - head = malloc(sizeof(node_t)); heao = malloc(sizeof(node_t)); - head->val = 0; heao->val = 9; - head->next=NULL; heao->next=NULL; - head->id=0; heao->id=0; + node_t * vga = NULL; node_t * imgpal = NULL; + vga = malloc(sizeof(node_t)); imgpal = malloc(sizeof(node_t)); + vga->val = 24; imgpal->val = 9; + vga->next=NULL; imgpal->next=NULL; + vga->id=0; imgpal->id=0; - for(i=1; i< + printf(" "); + for(i=1; i<= //PAL_SIZE - 7 + 6 ; i++) { if(!(i%3)) printf("\n "); printf("%d,", i); - pushe(head, i); + pushe(vga, i); } - printf("\n"); + printf("\n\n "); - for(i=8; i>0; i--) + for(i=4; i>0; i--) { if(!(i%3)) printf("\n "); printf("%d,", i); - pushe(heao, i); + pushe(imgpal, i); + } + printf("\n"); + + printf("size of vga = %d\n", listLength(vga)); +//#if 0 + printf("\n=======================\n"); + printf("vga list printings\n=======================\n"); + print_list(vga); + printf("\n=======================\n"); + printf("imgpal list printings\n=======================\n"); + print_list(imgpal); +// printf("\n=======================\n"); +//#endif + i=1;//skip overscan + while(i!=listLength(imgpal)) + { + } - print_list(head); + free(vga); + free(imgpal); +} +#else +#if 0 +/* C/C++ program to merge two sorted linked lists */ +// from http://www.geeksforgeeks.org/merge-two-sorted-linked-lists/ + +/* Drier program to test above functions*/ +void main() +{ + /* Start with the empty list */ + struct node* res = NULL; + struct node* a = NULL; + struct node* b = NULL; + + /* Let us create two sorted linked lists to test + the functions + Created lists, a: 5->10->15, b: 2->3->20 */ + pushll(&a, 15); + pushll(&a, 10); + pushll(&a, 4); + pushll(&a, 3); + pushll(&a, 2); + pushll(&a, 1); + pushll(&a, 0); + + pushll(&b, 20); + pushll(&b, 3); + pushll(&b, 2); + pushll(&b, 4); + printf("\n"); - print_list(heao); - free(head); - free(heao); + printf("The 2 Linked List are: \n"); + printList(a); printf("\n"); + printList(b); printf("\n"); + + /* Remove duplicates from linked list */ + res = SortedMerge(a, b); +// res = LL_merge(a, b); + + printf("Merged Linked List is: \n"); + printList(res); +} +#endif +/* C Program to remove duplicates from a sorted linked list */ + +/* Drier program to test above functions*/ +void main() +{ + /* Start with the empty list */ + struct node* head = NULL; + + /* Let us create a sorted linked list to test the functions + Created linked list will be 11->11->11->13->13->20 */ + push(&head, 20); + push(&head, 13); + push(&head, 13); + push(&head, 11); + push(&head, 11); + push(&head, 11); + + printf("\n Linked list before duplicate removal "); + printList(head); + + /* Remove duplicates from linked list */ + removeDuplicates(head); + + printf("\n Linked list after duplicate removal "); + printList(head); + } +#endif diff --git a/src/xcroll.c b/src/xcroll.c index cbbabea9..a73430af 100755 --- a/src/xcroll.c +++ b/src/xcroll.c @@ -28,7 +28,7 @@ //#define NOMAPLOAD //#define OLDPLAYERSPRITESTUFF -#define XC_CTRLTYPE ctrl_Joystick1//ctrl_Mouse//ctrl_Keyboard +#define XC_CTRLTYPE ctrl_Keyboard //Mouse #ifdef __DEBUG__ #define SCROLLEXEDEBUG