From: sparky4 Date: Fri, 22 Jun 2018 02:27:50 +0000 (-0500) Subject: removed linked list stuff of the palette. it is slow. also added more derived bianary... X-Git-Url: http://git.osdn.net/view?p=proj16%2F16.git;a=commitdiff_plain;h=932bccfc5b5fbfcc4cd6040cd7ef76f90cb9c1ea removed linked list stuff of the palette. it is slow. also added more derived bianary stuff --- diff --git a/16/ll.7z b/16/ll.7z new file mode 100755 index 00000000..d6718de0 Binary files /dev/null and b/16/ll.7z differ diff --git a/makefile b/makefile index bc228a0a..a478c66d 100755 --- a/makefile +++ b/makefile @@ -226,7 +226,6 @@ TESTEXEC3= & pcxtest2.exe UTILEXEC = & palettel.exe & - palllist.exe & palbomb.exe & palettec.exe & ps.exe @@ -303,7 +302,6 @@ vrstest.exe: vrstest.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) palettec.exe: palettec.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) palettel.exe: palettel.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) palbomb.exe: palbomb.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) -palllist.exe: palllist.$(OBJ) $(16LIB) gfx.lib $(DOSLIB) ll.$(OBJ) pcxtest2.exe: pcxtest2.$(OBJ) gfx.lib $(DOSLIB) #planrpcx.exe: planrpcx.$(OBJ) gfx.lib maptest.exe: maptest.$(OBJ) 16_map.$(OBJ) 16_head.$(OBJ) gfx.lib $(DOSLIB) $(16LIB) @@ -334,7 +332,6 @@ pcxtest2.$(OBJ):$(SRC)/pcxtest2.c $(SRCLIB)/16_vl.h palettec.$(OBJ): $(SRC)/palettec.c palettel.$(OBJ): $(SRC)/palettel.c palbomb.$(OBJ): $(SRC)/palbomb.c -palllist.$(OBJ): $(SRC)/palllist.c maptest.$(OBJ):$(SRC)/maptest.c $(SRCLIB)/16_vl.h #emmtest.$(OBJ):$(SRC)/emmtest.c #emsdump.$(OBJ):$(SRC)/emsdump.c @@ -437,7 +434,6 @@ vgmSnd.$(OBJ): $(VGMSNDLIB)/vgmSnd.c $(VGMSNDLIB)/vgmSnd.h #midi.$(OBJ): $(SRCLIB)/midi.c c_utils.$(OBJ): $(MODEXLIB)/c_utils.asm modex.$(OBJ): $(MODEXLIB)/modex.asm -ll.$(OBJ): $(SRCLIB)/ll.c $(SRCLIB)/ll.h bitmapl.$(OBJ): $(SRCLIB)/bitmapl.c $(SRCLIB)/bitmapl.h # diff --git a/src/lib/16_head.c b/src/lib/16_head.c index 4e8d3335..cda97037 100755 --- a/src/lib/16_head.c +++ b/src/lib/16_head.c @@ -324,9 +324,10 @@ _dl=_DL; // printf(" cf=%04x\npf=%04x\naf=%04x\nzf=%04x\nsf=%04x\ntf=%04x\nif=%04x\ndf=%04x\nof=%04x\n", _CF, _PF, _AF, _ZF, _SF, _TF, _IF, _DF, _OF); printf("cflag: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_cflag>>8), BYTE_TO_BINARY(_cflag)); // printf("cflag: %s\n",(_cflag)); - printf("dx: "NIBBLE_TO_BINARY_PATTERN""NIBBLE_TO_BINARY_PATTERN"\n", NIBBLE_TO_BINARY(_dx>>4), NIBBLE_TO_BINARY(_dx)); #endif + printf("dx: "NIBBLE_TO_BINARY_PATTERN""NIBBLE_TO_BINARY_PATTERN"\n", NIBBLE_TO_BINARY(_dx>>4), NIBBLE_TO_BINARY(_dx)); printf("dx: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_dx>>8), BYTE_TO_BINARY(_dx)); + printf("dx: "WORD_TO_BINARY_PATTERN"\n", WORD_TO_BINARY(_dx)); printf(" ---------------------------------------\n"); #endif diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 888773b9..3b0322b0 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -217,12 +217,35 @@ void regidump(); (byte & 0x02 ? '1' : '0'), \ (byte & 0x01 ? '1' : '0') +#define WORD_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c" +#define WORD_TO_BINARY(word) \ + (word & 0x8000 ? '1' : '0'), \ + (word & 0x4000 ? '1' : '0'), \ + (word & 0x2000 ? '1' : '0'), \ + (word & 0x1000 ? '1' : '0'), \ + (word & 0x0800 ? '1' : '0'), \ + (word & 0x0400 ? '1' : '0'), \ + (word & 0x0200 ? '1' : '0'), \ + (word & 0x0100 ? '1' : '0'), \ + (word & 0x0080 ? '1' : '0'), \ + (word & 0x0040 ? '1' : '0'), \ + (word & 0x0020 ? '1' : '0'), \ + (word & 0x0010 ? '1' : '0'), \ + (word & 0x0008 ? '1' : '0'), \ + (word & 0x0004 ? '1' : '0'), \ + (word & 0x0002 ? '1' : '0'), \ + (word & 0x0001 ? '1' : '0') + #define NIBBLE_TO_BINARY_PATTERN "%c%c%c%c" -#define NIBBLE_TO_BINARY(byte) \ - (byte & 0x08 ? '1' : '0'), \ - (byte & 0x04 ? '1' : '0'), \ - (byte & 0x02 ? '1' : '0'), \ - (byte & 0x01 ? '1' : '0') +#define NIBBLE_TO_BINARY(nibble) \ + (nibble & 0x08 ? '1' : '0'), \ + (nibble & 0x04 ? '1' : '0'), \ + (nibble & 0x02 ? '1' : '0'), \ + (nibble & 0x01 ? '1' : '0') + +#define BOOLEAN_TO_BINARY_PATTERN "%c" +#define BOOLEAN_TO_BINARY(boolean) \ + (boolean & 0x01 ? '1' : '0') #define PRINT_OPAQUE_STRUCT(p) print_mem((p), sizeof(*(p))) diff --git a/src/lib/ll.c b/src/lib/ll.c deleted file mode 100755 index 103388ae..00000000 --- a/src/lib/ll.c +++ /dev/null @@ -1,290 +0,0 @@ -#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->next != NULL) - { - printf("[%u]= %d\n", current->id, current->val); - current = current->next; - } -} - -void pushe(node_t * head, int val) -{ - node_t * current = head; - current->id = head->id; - current->next->id = current->id+1; - - while (current->next != NULL) - { - current->next->id = current->id; - current = current->next; - current->id++; - } - - // now we can add a new variable - current->next = malloc(sizeof(node_t)); - current->next->val = val; - current->next->next = NULL; - current->next->id++; -} - -void pushs(node_t ** head, int val) -{ - node_t * new_node; - new_node = malloc(sizeof(node_t)); - - new_node->val = val; - new_node->next = *head; - *head = new_node; -} - -int pop(node_t ** head) -{ - int retval = -1; - node_t * next_node = NULL; - - if (*head == NULL) { - return -1; - } - - next_node = (*head)->next; - retval = (*head)->val; - free(*head); - *head = next_node; - - return retval; -} - -int remove_last(node_t * head) -{ - int retval = 0; - node_t * current; - - /* if there is only one item in the list, remove it */ - if (head->next == NULL) { - retval = head->val; - free(head); - return retval; - } - - /* get to the last node in the list */ - current = head; - while (current->next->next != NULL) { - current = current->next; - } - - /* now current points to the last item of the list, so let's remove current->next */ - retval = current->next->val; - free(current->next); - current->next = NULL; - return retval; - -} - -int remove_by_index(node_t ** head, int n) -{ - int i = 0; - int retval = -1; - node_t * current = *head; - node_t * temp_node = NULL; - - if (n == 0) { - return pop(head); - } - - for (i = 0; i < n-1; i++) { - if (current->next == NULL) { - return -1; - } - current = current->next; - } - - temp_node = current->next; - retval = temp_node->val; - current->next = temp_node->next; - free(temp_node); - - 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; -} - -/* 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 deleted file mode 100755 index 159aa4ca..00000000 --- a/src/lib/ll.h +++ /dev/null @@ -1,38 +0,0 @@ -#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 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/pallist.txt b/src/pallist.txt new file mode 100755 index 00000000..69b30c3f --- /dev/null +++ b/src/pallist.txt @@ -0,0 +1,38 @@ +/* + * palllist experiment + */ +/* + * An experiment where I make 2 small linked list which points to 2 arrays + * one is the "hardware palette" array + * the other is "image palette" array + * and their respectable pointers point to their [i] stuff + * + * the palette updater stuff i want to make is this: + * + * VGA IMG + * 1- 2- + * 2- 4- + * 3- 0- + * 4- 9- + * 5- 0-(I will figure this out later if there is dup numbs) + * 6- + * 7- + * 8- + * + * MERGE THEM INTO + * + * VGA + * 1- + * 2->IMG[0] + * 3- + * 4->IMG[1] + * 5 + * 6 + * 7 + * 8 + * 9->IMG[3] + * 0->IMG[2]->IMG[4] + * + * i am going to work on a really big area of code it will be on the refresh system, the walking/scrolling system, things that use showpage, adding disableing 8087 functions if no 8087 detected, and a bunch of other things i cannot remember off the top of my head because i am BURNT. I need a small break~ -- -- -- -- update! i am working on this i made ZC_WALK and i am going to move to VRL/VRS soon! . + * ==== PRE SHOWPAGE TO SHOWMV CONVERSION ==== i am going to work on a really big area of code it will be on the refresh system, the walking/scrolling system, things that use showpage, adding disableing 8087 functions if no 8087 detected, and a bunch of other things i cannot remember off the top of my head because i am BURNT. I need a small break~ -- -- -- -- update! i am working on this i made ZC_WALK and i am going to move to VRL/VRS soon! + */ diff --git a/src/palllist.c b/src/palllist.c deleted file mode 100755 index e9367545..00000000 --- a/src/palllist.c +++ /dev/null @@ -1,182 +0,0 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2018 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover - * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Project 16 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ -/* - * palllist experiment - */ -/* - * An experiment where I make 2 small linked list which points to 2 arrays - * one is the "hardware palette" array - * the other is "image palette" array - * and their respectable pointers point to their [i] stuff - * - * the palette updater stuff i want to make is this: - * - * VGA IMG - * 1- 2- - * 2- 4- - * 3- 0- - * 4- 9- - * 5- 0-(I will figure this out later if there is dup numbs) - * 6- - * 7- - * 8- - * - * MERGE THEM INTO - * - * VGA - * 1- - * 2->IMG[0] - * 3- - * 4->IMG[1] - * 5 - * 6 - * 7 - * 8 - * 9->IMG[3] - * 0->IMG[2]->IMG[4] - * - * i am going to work on a really big area of code it will be on the refresh system, the walking/scrolling system, things that use showpage, adding disableing 8087 functions if no 8087 detected, and a bunch of other things i cannot remember off the top of my head because i am BURNT. I need a small break~ -- -- -- -- update! i am working on this i made ZC_WALK and i am going to move to VRL/VRS soon! . - * ==== PRE SHOWPAGE TO SHOWMV CONVERSION ==== i am going to work on a really big area of code it will be on the refresh system, the walking/scrolling system, things that use showpage, adding disableing 8087 functions if no 8087 detected, and a bunch of other things i cannot remember off the top of my head because i am BURNT. I need a small break~ -- -- -- -- update! i am working on this i made ZC_WALK and i am going to move to VRL/VRS soon! - */ -#include "src/lib/ll.h" - -#if 0 -//def OTHERMERGELISTSTIFF - -void -main(int argc, char *argv[]) -{ - int i; - 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; - - printf(" "); - for(i=1; i<= - //PAL_SIZE - 6 - ; i++) - { - if(!(i%3)) printf("\n "); - printf("%d,", i); - pushe(vga, i); - } - - printf("\n\n "); - - for(i=4; i>0; i--) - { - if(!(i%3)) printf("\n "); - printf("%d,", 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)) - { - - } - 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"); - 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 */ - pushll(&head, 20); - pushll(&head, 13); - pushll(&head, 13); - pushll(&head, 11); - pushll(&head, 11); - pushll(&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