コミットメタ情報

リビジョン40badd0143ad830bd4d873acb9a836f191cc6d57 (tree)
日時2018-06-14 23:39:19
作者sparky4 <sparky4@cock...>
コミッターsparky4

ログメッセージ

worked abit on the type_to_bianary functions

変更サマリ

差分

--- a/src/inputest.c
+++ b/src/inputest.c
@@ -67,6 +67,8 @@ main(int argc, char *argv[])
6767 gvar.player[0].enti.d=2;
6868 gvar.player[0].enti.spt=4;
6969
70+// wordtest();
71+ bytetest();
7072 //0000 nibbletest();
7173 //0000 booleantest();
7274 //printf("dbg_testkeyin=%u dbg_testcontrolnoisy=%u dbg_nogvar.playerinpu=%u\nloop if this is not responsive then please KILL or reset machine sorry!!\n", dbg_testkeyin, dbg_testcontrolnoisy, dbg_nogvar.playerinpu);
--- a/src/lib/16_head.c
+++ b/src/lib/16_head.c
@@ -323,6 +323,7 @@ _dl=_DL;
323323 // printf(" ip=%04x\n\n", _IP);
324324 // 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);
325325 printf("cflag: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_cflag>>8), BYTE_TO_BINARY(_cflag));
326+// printf("cflag: %s\n",(_cflag));
326327 #endif
327328 printf("dx: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_dx>>8), BYTE_TO_BINARY(_dx));
328329 printf(" ---------------------------------------\n");
--- a/src/lib/16_tail.c
+++ b/src/lib/16_tail.c
@@ -793,38 +793,53 @@ void turboXT(byte bakapee)
793793 }
794794 #endif
795795
796-const char *word_to_binary(word x)
796+//from https://stackoverflow.com/questions/18327439/printing-binary-representation-of-a-char-in-c
797+const char *word_to_binary(int x)
797798 {
798799 static char b[17];
799800 int z;
800801
801802 b[0] = '\0';
802- for (z = 16; z > 0; z >>= 1)
803+ for (z = 256; z > 0; z >>= 1)
803804 {
805+/// printf(" z=%u b=%u x=%u\n", z, b, x);
804806 strcat(b, ((x & z) == z) ? "1" : "0");
805807 }
806808 return b;
807809 }
808810
809-const char *nibble_to_binary(nibble x)
811+const char *byte_to_binary(int x)
810812 {
811813 static char b[9];
812814 int z;
813815
814816 b[0] = '\0';
815- for (z = 8; z > 0; z >>= 1)
817+ for (z = 128; z > 0; z >>= 1)
816818 {
817819 strcat(b, ((x & z) == z) ? "1" : "0");
818820 }
819821 return b;
820822 }
821823
822-const char *boolean_to_binary(boolean x)
824+const char *nibble_to_binary(int x)
823825 {
824826 static char b[9];
825827 int z;
826828
827829 b[0] = '\0';
830+ for (z = 8; z > 0; z >>= 1)
831+ {
832+ strcat(b, ((x & z) == z) ? "1" : "0");
833+ }
834+ return b;
835+}
836+
837+const char *boolean_to_binary(int x)
838+{
839+ static char b[3];
840+ int z;
841+
842+ b[0] = '\0';
828843 for (z = 1; z > 0; z >>= 1)
829844 {
830845 strcat(b, ((x & z) == z) ? "1" : "0");
@@ -832,13 +847,35 @@ const char *boolean_to_binary(boolean x)
832847 return b;
833848 }
834849
850+void wordtest()
851+{
852+ word pee;
853+ printf("wordtest\n");
854+ /* word to binary string */
855+ for(pee=0;pee<280;pee++)
856+ printf(" %u %s\n", pee, word_to_binary(pee));
857+ printf(" sizeof(word)=%s\n", word_to_binary(sizeof(word)));
858+ printf("end of word test\n");
859+}
860+
861+void bytetest()
862+{
863+ byte pee;
864+ printf("bytetest\n");
865+ /* byte to binary string */
866+ for(pee=0;pee<18;pee++)
867+ printf(" %u %s\n", pee, byte_to_binary(pee));
868+ printf(" sizeof(byte)=%s\n", byte_to_binary(sizeof(byte)));
869+ printf("end of byte test\n");
870+}
871+
835872 void nibbletest()
836873 {
837874 nibble pee;
838875 printf("nibbletest\n");
839876 /* nibble to binary string */
840877 for(pee=0;pee<18;pee++)
841- printf(" %u %s\n", pee, nibble_to_binary(pee));
878+ printf(" %u %s\n", pee, nibble_to_binary(pee));
842879 printf(" sizeof(nibble)=%s\n", nibble_to_binary(sizeof(nibble)));
843880 printf("end of nibble test\n");
844881 }
@@ -849,7 +886,7 @@ void booleantest()
849886 printf("booleantest\n");
850887 /* boolean to binary string */
851888 for(pee=0;pee<4;pee++)
852- printf(" %u %s\n", pee, boolean_to_binary(pee));
889+ printf(" %u %s\n", pee, boolean_to_binary(pee));
853890 printf(" sizeof(boolean)=%s\n", boolean_to_binary(sizeof(boolean)));
854891 printf("end of boolean test\n");
855892 }
--- a/src/lib/16_tail.h
+++ b/src/lib/16_tail.h
@@ -141,6 +141,12 @@ void DebugMemory_(global_game_variables_t *gvar, boolean q);
141141 void ClearMemory (global_game_variables_t *gvar);
142142 void Quit (global_game_variables_t *gvar, char *error);
143143 void turboXT(byte bakapee);
144+const char *word_to_binary(int x);
145+const char *byte_to_binary(int x);
146+const char *nibble_to_binary(int x);
147+const char *boolean_to_binary(int x);
148+void wordtest();
149+void bytetest();
144150 void nibbletest();
145151 void booleantest();
146152
旧リポジトリブラウザで表示