Set cycles to specific xt/at/386/486/586 speed.

Here you can discuss the development of patches.

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-01 @ 14:39

then we have been talking about different things. :)
you were talking about removing the == check from IF.
I supposed you wanted to do that to allow spaces for the first argument.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-01 @ 15:21

No, that's so it doesn't complain about spaces in the value, which is valid.
The error message, which I've commented out, isn't supposed to be there.
DOS 5.0 handles setting a variable with a value that has spaces, and doing an if empty check(if %var% == "") on a variable set to a value that has spaces.

There is no issue/contention/argument for/etc of spaces for the first argument.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-01 @ 15:30

It looks like a bit of a weirdness you are relying on. (At least in my opinion.)
Code: Select all
set VAR="a b"
if %VAR == "a b" dir    <-- no dir/error
if %VAR% == "a b" dir  <-no dir/error
if "%VAR" == "a b" dir    <-- no dir/error
if "%VAR%" == "a b" dir  <-no dir/error
if NOT %VAR == "" dir  <-gives dir
if "a b" == "a b"  <-syntax error
if %VAR "a b"  dir <- syntax error (omiting the ==)

So it only works for testing against emptiness, but not against the contents ?!
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-01 @ 15:53

Apparently. Again, the diff doesn't change the handling, just got rid of the error message that was in the way and not supposed to be there, and what I did add, the arithmetic, doesn't touch anything, its handling is encapsulated.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-01 @ 16:02

I will see I can add support for that. I was planning on adding the set /a support. but i didn't like the removal of the == test as that is required, there is something else wrong apparently. I have to think about it for a while to see how to support that. (testing for emptiness on variables with spaces in them).
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-01 @ 16:12

I'll do the same.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-01 @ 16:18

I'll probably add this btw (not related to this, but it is the same function)
Code: Select all
diff -aur dosbox/src/shell/shell_cmds.cpp dosbox-new/src/shell/shell_cmds.cpp
--- dosbox/src/shell/shell_cmds.cpp     Sun Sep  7 10:55:16 2008
+++ dosbox-new/src/shell/shell_cmds.cpp Sat Oct 25 14:11:17 2008
@@ -810,7 +810,12 @@
        }
        args += 2;
        StripSpaces(args);
-       char* woord2 = StripWord(args);
+//     char* woord2 = StripWord(args);
+       char* woord2 = args;
+       // Word is until space
+       while(*args && !isspace(*reinterpret_cast<unsigned char*>(args)))
+               args++;
+       if (*args) *args++ = 0;
        *end_word1 = 0;
        if ((strcmp(word,woord2)==0)==(!has_not)) DoCommand(args);
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-01 @ 16:31

I've found I can add back in the == check and still have the batch files work by getting rid of the isspace check on the variable.

Code: Select all
   // Word is until space or =
//   while(*args && !isspace(*reinterpret_cast<unsigned char*>(args)) && (*args != '='))
   while(*args && (*args != '='))   
      args++;
   char* end_word1 = args;
   StripSpaces(args);
   //Check for 2 ==
   
   if(strlen(args)<2 || args[0] != '=' || args[1] != '=') {
      SyntaxError();
      return;
   }
   
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-02 @ 11:11

Here's handling until space or =, except spaces inside the variable.

Code: Select all
   // Word is until space or =
   while(*args
    && (!(isspace(*reinterpret_cast<unsigned char*>(args)) && ((*args+1) == '=')))
    && (*args != '='))   
      args++;
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-04 @ 11:32

BTW, the last code snippet makes comparing strings work like in XP.

I think worrying about batch files being written to rely on the compares not working with spaces is baseless, but adding the following:

Code: Select all
   if (*woord2) {
     LOG_MSG("woord2 is not empty '%s'",woord2);
     char * firstword=word;
     while(*firstword) {  // check for spaces in first word
       if (isspace(*reinterpret_cast<unsigned char*>(firstword))) {
         LOG_MSG("dos 5.0 doesn't compare strings with spaces except for empty check; return");   
         return;
       } 
       firstword++;
     }
     char * secondword=woord2;
     while(*secondword) {  // check for spaces in second word
       if (isspace(*reinterpret_cast<unsigned char*>(secondword))) {
         LOG_MSG("dos 5.0 doesn't compare strings with spaces except for empty check; return");   
         return;
       } 
       secondword++;
     }
   }


to the change above would have it behave like DOS 5.0; allowing empty checks but no string compares on variables with spaces.

Code: Select all
   /* Normal if string compare */
   LOG_MSG("args='%s'",args);
   word = args;      
   // Word is until space or =   
   while(*args
    && (!(isspace(*reinterpret_cast<unsigned char*>(args)) && ((*args+1) == '=')))
    && (*args != '='))   
      args++;
   char* end_word1 = args;
   LOG_MSG("' =' args='%s'",args);   
   StripSpaces(args);
   LOG_MSG("stripspaces args='%s'",args);   
   //Check for 2 ==
   
   if(strlen(args)<2 || args[0] != '=' || args[1] != '=') {
      SyntaxError();
      return;
   }
   
   args += 2;
   LOG_MSG("minus '==' args='%s'",args);      
   StripSpaces(args);
   LOG_MSG("minus '==' stripspaces args='%s'",args);      
   char* woord2 = StripWord(args);   
   LOG_MSG("stripword woord2='%s'",woord2);      
   *end_word1 = 0;   
   
   if (*woord2) {
     LOG_MSG("woord2 is not empty '%s'",woord2);
     char * firstword=word;
     while(*firstword) {  // check for spaces in first word
       if (isspace(*reinterpret_cast<unsigned char*>(firstword))) {
         LOG_MSG("dos 5.0 doesn't compare strings with spaces except for empty check; return");   
         return;
       } 
       firstword++;
     } 
     char * secondword=woord2;
     while(*secondword) {  // check for spaces in second word
       if (isspace(*reinterpret_cast<unsigned char*>(secondword))) {
         LOG_MSG("dos 5.0 doesn't compare strings with spaces except for empty check; return");   
         return;
       } 
       secondword++;
     }
   }          
   if ((strcmp(word,woord2)==0)==(!has_not)) DoCommand(args);


ie. this is the fix.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Perplexia » 2008-11-06 @ 04:58

When I run the setup file for heroes of might and magic, it tells me the speed of my "cpu" in dosbox. I don't know how accurate it is, but I can sort of use it to gauge by.

Quick question: When I set a cycle amount, for example 20000, it tells me I have a 486 @ 425 mhz. No matter how high I set the cycles, it always detects a 486, even beyond 1500mhz. So my question is, would there be a theoretical difference in performance between, say, a 425 mhz 486 and a 425 mhz Pentium processor? Or put another way, if Dosbox emulated a Pentium processor at that speed rather than a 486, would there be an increase in demand from the host and/or an increase in performance?
Perplexia
Newbie
 
Posts: 8
Joined: 2006-4-17 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-06 @ 11:44

theoretical they are different. However for your game it probably it doesn't matter.

ih8regs. I'll look at your code. Got another patch for IF as well on sourceforge. So I want to test the 2 together.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-06 @ 14:17

help(-h, /h, -?, /? etc.) isn't working in the latest incarnation, so need to run the bug down.

Perplexia,

Always reporting 486@425MHz would be a limitation of the program's detection function. There is an actual difference between a 486 and Pentium at any speed. Some opcodes are faster on the 486, with the pentium faster overall. DOSBox emulating a Pentium would mostly mean handling the added opcodes. As has been covered, DOSBox doesn't track opcode cycles, opcodes are seen as opcodes, not 486 or pentium opcodes. There's likely more overhead to emulating a pentium, so there'd be an increase demand on the host. Programs that would use pentium opcodes, optimized for a pentium, emulation optimizations of the pentium handling, .. could see an increase in performance in spite of additional overhead, but overall likely no difference.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 09:34

What's with end_word1? I don't see it used anywhere, just set, yet if I comment it out, things are screwed up. What, when, where, how is it used?

This is what's causing help not to work:

Code: Select all
   while(*args
  && (!isspace(*reinterpret_cast<unsigned char*>(args)))   
//    && (!(isspace(*reinterpret_cast<unsigned char*>(args)) && ((*args+1) == '=')))
    && (*args != '='))   
      args++;


The original line "&& (!isspace(*reinterpret_cast<unsigned char*>(args)))" produces the string " == "-h" goto finish", having a space at the beginning.

// && (!(isspace(*reinterpret_cast<unsigned char*>(args)) && ((*args+1) == '='))) produces the string "== "-h" goto finish", without a space at the beginning.

The following stripspaces(args) gets rid of the leading space of the original line at which point they're the same.

The difference is what end_word1 is set to just prior to stripspaces.

end_word1 is a local variable of CMD_IF, its only references in all of DOSBox being inside CMD_IF, both the lines setting end_word1, yet it's being used as a global variable somehow somewhere, and it's where the help handling is breaking.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-07 @ 09:51

look just above the strcmp (the last line)

the patch on sourceforge was updated as well to update IF a lot.

(it's in bugs called several small bugs)

I haven't tested it yet.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 10:19

I figured it out, (*args+1) should be *(args+1) in && (!(isspace(*reinterpret_cast<unsigned char*>(args)) && ((*args+1) == '=')))
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 10:36

There's debugging to do with his patch as it crashes, but right off,

// Check parameters
if (!*word || !*woord2 || (strcasecmp(word,"NOT")==0)) {
SyntaxError();
return;
}

bars empty check handling, which is wrong.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 11:19

- if (strncasecmp(args,"NOT ",4) ==0) {
+ while (strncasecmp(args,"NOT ",4) ==0) {
args += 4; //skip text
//skip more spaces
StripSpaces(args);
- has_not = true;
+ has_not = !has_not;
}

All I see is different coding style here.

- StripSpaces(args);
+// StripSpaces(args);
+
+ // ignore all characters until =
+ while(*args && (*args != '='))
+ args++;
+

All I see here is the same result minus the function call overhead.

- char* woord2 = StripWord(args);
+// char* woord2 = StripWord(args);
+
+ char* woord2 = args;
+ // Word is until space
+ while(*args && !isspace(*reinterpret_cast<unsigned char*>(args)))
+ args++;
+ if (*args) *args++ = 0;
+ // 2nd word must terminated with space in msdos 5.0 but command line is trimmed in dosbox
+/* else {
+ SyntaxError();
+ return;
+ }
+*/

This is the fix, except it crashes which I haven't gotten around yet, and it doesn't handle variables with spaces, which it should.

+
+ // Check parameters
+ if (!*word || !*woord2 || (strcasecmp(word,"NOT")==0)) {
+ SyntaxError();
+ return;
+ }
+

Incorrect, do not add.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-07 @ 12:15

i don't share your conclusions

the first one: it makes more then one NOT possible. if NOT NOT a==b (hence the has_not = !has_not )
the second one: StripSpaces isn't the same as read until a '='
Need to example the third and other parts a bit more closely though. There is just so much code snippets in this thread now.
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10556
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 12:16

I don't know how he arrived at 2nd word must be terminated with space, adding such would always make the strings not match. Testing DOS 5.0 shows this is incorrect, DOS 5.0 returns "Bad command or file name" if you try to compare with a trailing space(set val=word1; if "%val%" == "word1 ".) Top it off, such has nothing to do with his description of problem 8 on sourceforge, which is an issue with the handling of quotes on the left variable. I see nothing in the patch that fixes problem 8.

I'll take your word on the first, second isn't the same, but same result. I'm not sure what you mean with about the third. If you're asking me to clarify what I said, dosbox crashes, shutsdown, if either the third or fourth part is included, so I haven't tested as I haven't been able to run it. Looking at it I know it doesn't handle variables with spaces, as the while breaks on !isspace=false, so it will end the string on the first space it hits. The fourth, returns before comparing if woord2 is empty, thereby preventing empty check.
Last edited by ih8registrations on 2008-11-07 @ 12:39, edited 1 time in total.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

PreviousNext

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest