News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Wanting to understand Restunts source code structure

Started by Cas, August 28, 2022, 11:24:08 PM

Previous topic - Next topic

Daniel3D

#15
So if i understand correctly. Starting with seg041 (which is a small one luckily)
..model medium
nosmart
.stack 8000
    include structs.inc
    include custom.inc
    include seg000.inc
    include seg001.inc
    include seg002.inc
    include seg003.inc
    include seg004.inc
    include seg005.inc
    include seg006.inc
    include seg007.inc
    include seg008.inc
    include seg009.inc
    include seg010.inc
    include seg011.inc
    include seg012.inc
    include seg013.inc
    include seg014.inc
    include seg015.inc
    include seg016.inc
    include seg017.inc
    include seg018.inc
    include seg019.inc
    include seg020.inc
    include seg021.inc
    include seg022.inc
    include seg023.inc
    include seg024.inc
    include seg025.inc
    include seg026.inc
    include seg027.inc
    include seg028.inc
    include seg029.inc
    include seg030.inc
    include seg031.inc
    include seg032.inc
    include seg033.inc
    include seg034.inc
    include seg035.inc
    include seg036.inc
    include seg037.inc
    include seg038.inc
    include seg039.inc
    include dseg.inc
    include seg041.inc
seg041 segment byte public 'STACK' use16
    assume cs:seg041
    assume es:nothing, ss:nothing, ds:dseg
seg041 ends
end

The line
Quoteseg041 segment byte public 'STACK' use16

Has to be
Quoteseg041 segment para public 'STACK' use16

Do they need to be changed in the ASM file and the INC file simultaneously for each segment?
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

llm

QuoteDo they need to be changed in the ASM file and the INC file simultaneously for each segment?

yes all segment names/definitions need to be equal

AND you should base on the original asm - i have no idea if you and Cas checked if the exe changed with your extension in an unwanted way (what does not mean in any way that it would crash, could be that it just works but still wrong)

Daniel3D

#17
Cas and I used asmorig in all cases. Also checked the executable against game.exe (the execombined executable)
Al changes in the code are local and besides a offset with the last modification there are no differences besides what is to be expected as far as I can tell.

We didn't touch the version with c code substitution because that brings extra uncertainty to the mix.
We kept it as close to unmodified original as possible.
Now we know more we could try the same thing with c code. See what effect that has and if that works better or not.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

llm

Quote from: Daniel3D on September 06, 2022, 11:37:42 AMCas and I used asmorig in all cases. Also checked the executable against game.exe (the execombined executable)

im mean the unchanged asmorig - just to prevent other problems with your extensions
(it a clean test that do not need to happen in a already changed source)

Quote from: Daniel3D on September 06, 2022, 11:37:42 AMAl changes in the code are local and besides a offset with the last modification there are no differences besides what is to be expected as far as I can tell.

your changes must move code and offsets - because new code can't be of size 0 (or did Cas magic?)

Quote from: Daniel3D on September 06, 2022, 11:37:42 AMWe didn't touch the version with c code substitution because that brings extra uncertainty to the mix.
We kept it as close to unmodified original as possible.
Now we know more we could try the same thing with c code. See what effect that has and if that works better or not.

its very possible to only use c code for your extensions - adding a new segment for example and some patching, the other c ports are not needed to use c code for your stuff

Daniel3D

Oh, right. For this new thing we will use unchanged original code.
Every modification was made as stand alone if possible.

Exept for the multiple needle color all modifications are only values, so no offset changes.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Daniel3D

Only the modification that makes it possible to give both meter needles different colors introduces new code.

The change of default car is pure values.
The position of the main menu buttons is pure values.
The first color of both needle change is a redirect to a different source but the same length.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

As Daniel3D pointed out, only the dual colour mod pushes new code into the file. Not sure what "in an unwanted way" would be. I mean, if it crashes, it's clear it's unwanted, ha, ha... but if it doesn't, then we'd have to agree on what is unwanted. Yes, it could be "unstable", like, it doesn't crash, but may crash, sometimes.... But so far, that hasn't happened. If at any time, an instability were found, I'd recommend using the single colour mod instead.

Even the dual colour mod is too simple to justify using a C compiler.

It is possible to have zero-length code... in a way. This is what many viruses do. You analyse the original code, then make it shorter by either using more space-efficient code or dropping things that are not being used. Finally, use the newly available space to introduce new code.

And about magic... the guys at flatassembler.net, some appear to have obtained their degrees at Hogwarts  :o
Earth is my country. Science is my religion.

llm

Quote from: Cas on September 06, 2022, 08:44:39 PMIt is possible to have zero-length code... in a way. This is what many viruses do. You analyse the original code, then make it shorter by either using more space-efficient code or dropping things that are not being used. Finally, use the newly available space to introduce new code.

im well aware of that and using it activly in some of my reversing projects
im in the assembler,C/C++, reversing, disassembling area more or less full time per day for the last 15 years - there is nearly nothing i haven't touched in that time :)

llm

did it work to change the segment alignment to para?

Daniel3D

Quote from: llm on September 09, 2022, 11:18:02 AMdid it work to change the segment alignment to para?
I don't know. I can't do much until I get a new laptop or fix the other one..
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

I haven't tried changing that.

Oh, it's great that you've kept your C and assembly polished throughout the years. I've had times and times. As you know, I've been wanting to start working more in C, but the lack of native graphics (native to the compiler, that is) has been stopping me.

One thing I've been considering is to use a workaround: make myself a wrapper libarary for XLib that looks like graphics.h more or less. Then of course, my programs would only compile for GNU/Linux, but because of the wrapper, another wrapper could be made, compatible with it, that would fall back to, say, SDL, in the Windows platform. This way, I'm not forced to using a shared library in the OS I use, but people are able to use my software whatever way they prefer. For DOS, I would just make an assembly version of the "wrapper" that would go directly to the hardware.
Earth is my country. Science is my religion.

llm

Quote from: Cas on September 10, 2022, 04:08:18 AMOh, it's great that you've kept your C and assembly polished throughout the years.

im working in this business - would be sad if i would stop polishing it :)

Quote from: Cas on September 10, 2022, 04:08:18 AMAs you know, I've been wanting to start working more in C, but the lack of native graphics (native to the compiler, that is) has been stopping me.

ever tried Allegro? https://liballeg.org
Version 4.2 supports DOS (Allegro 4.4+ removed the support) https://liballeg.org/readme.html 

QuoteAllegro 4
Allegro 4 is the classic library, whose API is backwards compatible all the way back to Allegro 2.0 for DOS/DJGPP (1996). It is no longer actively developed, but we still apply patches sent to us by contributors, mainly to fix minor bugs. Every so often we will make new releases.

Allegro 4.4 supports the following platforms:

Unix/Linux
Windows (MSVC, MinGW, Cygwin)
MacOS X
Haiku/BeOS
PSP (currently in git repository only)
The older Allegro 4.2 branch additionally supports:

Windows (Borland)
QNX
DOS (DJGPP, Watcom)

i don't know if its worth to invest time in this area to come up with your own solution
just wrap the stuff in you graphs.h/c and replace it later when everything is working - the best
pixel drawing routine is for nothing if its not called for doing something magical :)

Cas

I've heard about Allegro and have been browsing its site many times, but never actually worked with it. If it can be statically compiled and doesn't get too big, it could work for me. Since the old version supports DOS, I reckon it does fit in that category.

I have a problem with including third party software in my work and it has to do with licensing. In part, it's just because of something I don't know very well, but it's also a matter of discomfort. I'll explain...

I usually make my programs GPLv3 unless I'm making them only for myself, in which case I don't apply a license (all rights reserved). Of course, this means that I can only use libraries that are compatible with the GPLv3. I think Allegro is. Now, the thing is, when I later distribute my program, I have to make the source available, but then this means I have to also make the library source available, since it's part of the program code now. Am I correct?

Including all the source is very untidy and complicates the compiling for whoever downloads the source, but if I include a precompiled version of the library, the package gets even bigger. So I don't know what's the best solution for this. To make matters worse, if the library has dependencies, now I have to include the source code of those dependencies as well. Each dependency will be written in a different style and have its compilation parameters, etc.

Now say I'm wrong and I can just leave out the source code that I didn't make, then this is what brings me the discomfort: I know I wouldn't really be providing the user with all they need to compile the program, so I feel it's cheating.

So... that's my issue with third party libraries, ha, ha. What would you do about this?  How would you handle it?
Earth is my country. Science is my religion.

Daniel3D

As a user i like the option.
So basically a three step download.

  • Just the program with what it needs to run.
  • with your source and references to third parties used,
  • With source and third party stuff as you used them.

The last should be a static addition because all code and changes are in the second developer version.

But sometimes third party stuff disappears and a being able to supply it is smart.

I don't know if i describe it correctly because i always go for option one.
But this is what I see when i look for software.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Right. When I am the user and I download software, I rarely download the source unless I want to compile it for some reason or examine the code. Most of the free software code around today is written in horrible languages such as java, ha, ha or using lots of OOP, so studying the source normally isn't of any use to me. Then it's good to have an option like your #1.

Of course, if I split it, then people have to be aware that they can't redistribute package #1 without also putting the other packages available at the same location.
Earth is my country. Science is my religion.