Commit Graph

174 Commits

Author SHA1 Message Date
nmlgc 43001161e3 [Maintenance] Fix any whitespace issues in our own code 2015-09-07 15:44:48 +02:00
nmlgc c2a8c221f2 Let Turbo C++ link in the Borland C/C++ runtime for the main EXE files
This took long enough, so we're not covering the COM files right now. Like, I
can't even tell how you're supposed to work around the forced word alignment
for the _TEXT segment. Guess we'll just have to decompile all of these in one
go, just like we did with ZUNSOFT.COM.

Also, it really seems as if we're merely trading one ugly workaround for
another in our quest for identical binaries.
2015-02-19 10:22:00 +01:00
nmlgc 2d5d38426f Finally use standard segment names everywhere
And I guess we just have to ignore and disable that segment alignment warning
for TH01. It's not like this changes anything in the binary.
2015-02-18 14:04:43 +01:00
nmlgc 60f6ecec84 [Reverse-engineering] [th01/zunsoft] Identify all global variables
Yup, the code for the first ZUN Soft logo is now completely position-
independent and ready to be decompiled.

(Also, TIL that the PC-98 GRCG has hardware support for double-buffering
through page flipping. Heh, at least one feature that makes it a viable system
for games...)
2015-01-13 18:10:24 +01:00
nmlgc bfa3829003 [Reduction] #705-708: Remaining third-party functions in TH02's ZUN_RES.COM 2014-12-01 05:16:41 +01:00
nmlgc 3f1c1eba6d [th02/zun_res] Reduce all known library functions
From what I can tell, this program does exactly three things:
• preparing the initial high score list
• writing default settings to HUUMA.CFG
• and allocating the game's resident configuration structure and writing its
  segment address to bytes 6-7 of HUUMA.CFG

All that results in a COM file of 6.84 KiB, 83% of which is library code.
That's why C was once seen as a bloated high-level language as well.
2014-12-01 03:25:30 +01:00
nmlgc 5ad97a08ea [JWasm move] Fix the remaining small issues to get through the first pass
Thanks to the LOCALS directive, we do need to break compatibility to TASM at
one point after all. This is the rest we can reasonably change to get at least
through JWasm's first pass without errors while maintaining compatibility to
TASM.

Includes:
* the OPTION syntax to switch in and out of floating-point emulation mode
* REP CMPSB → REPE CMPSB
* Hacks for two 80-byte short jumps
* lack of support for floating-point stupidity ♥
as well as other issues that I covered in previous commits and overlooked in
some files.
2014-11-21 11:24:47 +01:00
nmlgc 2279e82167 [JWasm move] Use unique global names for local labels where it matters
From the TASM manual:
"NEAR labels defined with the colon directive (:) are considered block-scoped
if they are located inside a procedure, and you've selected a language
interfacing convention with the MODEL statement. However, these symbols are
not truly block-scoped; they can't be defined as anything other than a near
label elsewhere in the program."

MASM's own local label syntax - declaring labels using @@ and then jumping to
the next and previous @@ using @F and @B - is obviously too limiting for any
longer function, and is not even supported by TASM unless we switch it to MASM
mode completely.

While this is indeed ugly, it only affected 16 files, which is way less than
what we would get in a TASM build without LOCALS. In comparison to having a
modern, cross-platform assembler, that really is a small price to pay.
2014-11-21 08:40:41 +01:00
nmlgc 5e35cfb1af [JWasm move] Fix improper structure declarations
Really, Borland? You considered it necessary to add directives for object-
oriented programming (in Assembly!) and convenience features like bitfield
records or PUSHSTATE/POPSTATE, yet you never came up with the actually
*helpful* idea of just adding a simple basic pointer data type that depends
on the current memory model's data size?
Like, something like DP... oh wait, that's already taken, as an alias for
DF, the 48-bit 80386 far pointer type.

And this, exactly, is the problem with assemblers. The language itself is
undefined beyond the instructions themselves, but it's obviously very
uncomfortable to program anything with just that, so your assembler needs to
add custom directives on top of that, and of course everyone has different
ideas of the features and use cases that should (and should not) be covered by
syntax. (I'm looking especially at you, NASM.)

And then one of those developers sells their compiler division to a different
company, which then subsequently discontinues all products without ever
releasing the source code, trapping their nice extensions in a single
executable for a single platform that is not even legally available anymore.

tl;dr: http://xkcd.com/927/
2014-11-20 04:55:57 +01:00
nmlgc 877804c739 [JWasm move] Prefixes must be on the same line as the modified instruction 2014-11-19 07:31:59 +01:00
nmlgc e551d590bd [JWasm move] Fix the interrupt vector declarations in c0[data].asm
The leniency! It hurts!
2014-11-19 07:26:12 +01:00
nmlgc af1ce6cad8 [JWasm move] Specify struct names where necessary
It may look redundant and it surely bloats the code, but well, registers don't
have types, so it really *is* good coding style to do this everywhere.
2014-11-19 07:15:10 +01:00
nmlgc af5419e350 Fix the directory of the fperror() slices
(Damn, the other commit prepared for today is not getting done, why does IDA
have to be so terrible...!)

Anyway, here's a small consistency edit instead.
2014-11-11 23:42:56 +01:00
nmlgc 87a682dd4f [Reduction] #695-696: User entry points for read() and write()
That's it, segment 0 cleared out in all executables of TH01! Only missing that
last floating-point slice now...
2014-11-10 22:20:59 +01:00
nmlgc 7705bea1f9 [Reduction] #694: scanf 2014-11-10 21:42:09 +01:00
nmlgc 4c30e5e974 [Reduction] #693: scanner 2014-11-10 21:04:32 +01:00
nmlgc 8386db1cb9 [Reduction] #692: coreleft 2014-11-10 19:58:08 +01:00
nmlgc 6ab63bc2ab [Reduction] #691: farcoreleft 2014-11-10 19:19:33 +01:00
nmlgc dfc9361b33 [Reduction] #690: farcalloc 2014-11-10 19:11:34 +01:00
nmlgc 1681595338 [Reduction] #689: Long pointer+scalar addition
This file has been lying around there for almost three months now, because I
initially couldn't describe its functionality...
2014-11-10 19:10:46 +01:00
nmlgc f7cb71193b [Reduction] #686-688: scantod 2014-11-10 01:02:11 +01:00
nmlgc 84180b9cd9 [Reduction] #685: ldtrunc 2014-11-09 14:49:18 +01:00
nmlgc 03139534f7 [Reduction] #684: control87 2014-11-09 13:18:19 +01:00
nmlgc 13b10ef589 [Reduction] #683: access (the one that *actually* has no underscore) 2014-11-09 11:58:33 +01:00
nmlgc 986590f321 [Reduction] #682: ftol
And surprisingly, TH01's OP.EXE ends up as the first game executable that has
its seg000 cleared out.
2014-11-09 01:11:04 +01:00
nmlgc 408fe19952 [Reduction] #681: ungetc 2014-11-08 11:45:33 +01:00
nmlgc cab8db3ce2 [JWasm move] "addr" is a reserved word 2014-11-07 12:38:54 +01:00
nmlgc 52209cbcdf [JWasm move] Add symbol names to the ENDP and ENDS directives where necessary 2014-11-06 06:45:35 +01:00
nmlgc 4dc9b9ab4a [JWasm move] Don't use the DIST/CALLMODEL constants for procedures and labels
Once you've actually found the right syntax that makes the assembler just use
the default call type of the current memory model for both procedures (where
it's just "PROC" without anything else) and labels (where it's "LABEL PROC"),
these constants become completely unneccessary, even with TASM.
2014-11-05 18:20:02 +01:00
nmlgc 0b34460155 [Reduction] #670-672: e087_Trap
I guess this marks the final demystification of how segment declarations work
and how they are compiled. However, it only really makes sense for anything
outside the TEXT segment, like these floating-point functions. As long as the
slices aren't immediately next to each other, it would still be annoying to
have segment declarations inside of them, since we'd have to copy-paste these
declarations around every INCLUDE directive...
2014-11-02 20:11:20 +01:00
nmlgc 3a1c2fd679 Move the stack segment into its own slice
Saves 141 lines, and we'll need to ASSUME it in the upcoming floating-point
slices.
2014-11-02 19:44:02 +01:00
nmlgc a777ad2ad1 [Reduction] #668-669: pow10 2014-11-02 16:41:47 +01:00
nmlgc 0856fab827 [Reduction] #576-667: emu086.asm 2014-11-02 11:20:05 +01:00
nmlgc 7790ecdb7c [Reduction] #574-575: vprinter
And that would be the final function of the printf() family!
2014-11-02 09:01:46 +01:00
nmlgc 6d422052ca [Reduction] #570-573: realcvt 2014-11-02 08:27:17 +01:00
nmlgc 015ceec3e1 [Reduction] #569: xcvt
... and even with EMUL being set up and working, TASM still needs to be hacked
into actually emitting emulator calls for certain instructions.
2014-11-02 06:55:48 +01:00
nmlgc bbd8ff96ab [Reduction] #563-568: Floating-point emulator initialization
Finally - and there was indeed no way around switching to JWlink, as ALINK
v1.6 refuses to link the TH01 executables with a nondescript "Undefined base
seg" message once nec_fpinit.asm is included.
2014-11-01 17:09:13 +01:00
nmlgc 48088875ca [Reduction] #561-562: scantol
Also finally getting a macro for the recurring "pop cx if LDATA" case.
2014-10-30 09:38:46 +01:00
nmlgc 696d7f9476 Identify the missing BSS slice of xxv.cpp
sigdata.c doesn't specify any alignment, so this is the only position that
makes sense.
2014-10-29 05:41:43 +01:00
nmlgc 935e68f35e [Reduction] #560: puts 2014-10-29 05:34:30 +01:00
nmlgc 2d62776e02 [Reduction] #559: printf 2014-10-28 03:01:42 +01:00
nmlgc c4aee8a236 [Reduction] #556-558: open 2014-10-27 02:50:32 +01:00
nmlgc ebd20ebc88 [Reduction] #554-555: __rtl_open/__open
Same situation as with __rtl_close/__close, __rtl_read/__read and
__rtl_write/__write.
2014-10-26 02:16:29 +02:00
nmlgc d7d9758fac [Reduction] #553: C++ vector_new 2014-10-25 02:53:27 +02:00
nmlgc 2c2977aa69 [Reduction] #552: Far new[] operator 2014-10-24 03:00:29 +02:00
nmlgc 0b6a824296 [Reduction] #551: Far new operator 2014-10-23 02:01:06 +02:00
nmlgc 4c12d226a4 [Reduction] #550: lrotr 2014-10-22 13:45:02 +02:00
nmlgc c9ee6b0aef [Reduction] #549: lrotl 2014-10-21 03:46:42 +02:00
nmlgc 340c8a792a General cleanup
Mostly moving spurious null bytes, which are actually supposed to denote
alignment, into their associated slices, but also prettying up some of the
very first slices.
2014-10-20 17:20:04 +02:00
nmlgc 1c72d7e242 [Reduction] #548: Floating-point emulation data
Well, we have to start reducing this mess somewhere. The actual reduced
initialization code I've been preparing still fails to compile, and the data
is shared with a number of other components anyway, so...
2014-10-19 23:37:46 +02:00