Commit Graph

257 Commits

Author SHA1 Message Date
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 4ac17ac2a5 Trick TASM into not creating 32-bit default segments
So that's the - admittedly rather weird - solution to the problem that has
been plaguing this project ever since the beginning of the reduction step.
Without any 32-bit dummy segments in the compiled object files, more linkers
will be able to build this project, one of them being JWlink
(http://sourceforge.net/projects/jwlink/).

Still can't rename dseg to _DATA though, as TASM stupidly refuses to accept
any ALIGN directives above a segment's alignment attribute value. TH01's
floating-point data slices already require larger alignments, and we're very
likely to have even more of those in the future.

Also, we're finally defining the Borland C++ model symbols directly in the
code, rather than in my unpublished build batch files. :)
2014-10-31 08:17:54 +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 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
nmlgc 658ed9e72b Move "Abnormal program termination" to its own slice
That was the very first function reduced, before I came up with the data slice
model in 59688e23fc.
2014-10-12 18:37:58 +02:00
nmlgc 4625339af1 Identify all remaining nopcalls 2014-10-07 06:32:20 +02:00
nmlgc eace57b1a2 Wrap all code segments into their own group
Necessary to keep the original segment ordering with ALINK, our new linker.
2014-09-22 22:19:29 +02:00
nmlgc 00e2dcb519 Remove comments containing garbage characters
... as well as other useless comments that were in close proximity to those.
Now, all files should be valid Shift-JIS.
2014-09-18 20:41:06 +02:00
nmlgc 86b86a96b8 [Reduction] #503: graph_gaiji_puts 2014-09-15 03:03:52 +02:00
nmlgc a4a5bc9df9 [Reduction] #502: graph_gaiji_putc
Introducing MASTERMOD v3. How long until a GAME_NUMBER macro? (Answer: Once we
find ZUN code that slightly changed between games.)
2014-09-14 17:39:30 +02:00
nmlgc 80fc5c6d82 [Reduction] #496: mem_unassign
Which challenges a lot about what we thought to know about Amusement Makers'
modifications to master.lib, due to the fact that TH02 contains the modified
version of this function, but the original of draw_trapezoid...

And I haven't even begun to research how this removal of conditional branches
could have a positive effect on the game, especially since it's only called
before exiting anyway.
2014-09-08 20:47:09 +02:00
nmlgc 23a3a4116a [Reduction] #479-482: pfgetc 2014-09-07 15:07:36 +02:00
nmlgc 99b60ff9b9 [Reduction] #473: execl
And thus, we've singled out all Borland C++ runtime functions in all games but
TH01.
2014-09-06 19:08:18 +02:00
nmlgc d575a37e1e [Reduction] #470-472: LoadProg 2014-09-06 19:07:54 +02:00
nmlgc ccc560ab37 [Reduction] #466: searchenv 2014-09-04 20:55:28 +02:00
nmlgc dc9fc37b3f [Reduction] #465: searchstr 2014-09-04 20:55:27 +02:00
nmlgc c0aa5b8a67 [Reduction] #461-463: fullpath.c 2014-09-04 19:04:39 +02:00
nmlgc af7f0b0ad6 [Reduction] #458-460: Double-byte character set functions 2014-09-03 23:23:25 +02:00
nmlgc bab649b884 [Reduction] #457: getch 2014-09-03 19:30:32 +02:00
nmlgc e54a6ad120 [Reduction] #456: DOSCMD
... I, um, cannot comprehend how the C source code I have for this function
could have been compiled into such an assembly.
2014-09-03 19:13:47 +02:00
nmlgc 92046a8021 [Reduction] #455: getenv 2014-09-03 17:08:02 +02:00
nmlgc 3f7a29acc6 [Reduction] #452: respal_free 2014-09-03 15:45:21 +02:00
nmlgc 61c95ec603 [Reduction] #450-451: respal_exist and respal_create 2014-09-03 15:23:51 +02:00
nmlgc 01a126da71 [Reduction] #449: setvbuf 2014-09-03 14:02:14 +02:00
nmlgc 00e419e9da [Reduction] #448: setblock 2014-09-02 23:38:26 +02:00
nmlgc b77f2cfba0 [Reduction] #447: access 2014-09-02 23:26:19 +02:00
nmlgc 23aa61c002 [Reduction] #446: abort
The one with the single underscore, which is just raise + a wrapper around the
one with two underscores.
2014-09-02 21:45:19 +02:00
nmlgc 9d5aa934d4 [Reduction] #445: flushall 2014-09-02 21:44:35 +02:00
nmlgc 429f134a51 [Reduction] #442-444: fseek and ftell 2014-09-02 21:04:29 +02:00
nmlgc 6250206235 [Reduction] #432-440: xxv.cpp
OK, *that's* the last piece of C++ crud shared across all main executables.
According to the object in the library file though, it seems to include one
more dword named
	__DestructorCountPtr
in the BSS segment. Neither games nor the runtime itself seem to use it, and
as a consequence, it doesn't even seem to be included in the games' BSS
segments, given that they all end with the symbols of xx.cpp...
2014-09-01 13:51:23 +02:00
nmlgc f994832a28 [Reduction] #431: toupper
Neither is this one. Also, interesting how IDA didn't identify the function in
one third of the cases.

[Binary change] Order of 2 relocations in TH03's MAINL.EXE, TH04's MAIN.EXE
and MAINE.EXE, and TH05's MAINE.EXE.
2014-09-01 12:01:35 +02:00
nmlgc 4e16a92b07 [Reduction] #429: ctype 2014-09-01 12:01:32 +02:00
nmlgc 5b91dd3b42 [Reduction] #423: grcg_polygon_c 2014-09-01 06:52:28 +02:00
nmlgc b2c9ba67bc [Reduction] #422: draw_trapezoid
Yup. From TH03 on, ZUN uses a different version of master.lib, containing more
features than the last official version 0.23 from May 1995. Given the relative
insignificance of the features in question, I presume that Amusement Makers
must have kept their own, improved fork of master.lib, rather than ZUN having
hacked master.lib on his own.

Anyway, that doesn't matter. In the end, we still have to reverse-engineer each
and every one of these changes, and some of the more complicated functions
won't even be reduced before the actual reverse-engineering step of this
project.

[Binary change] Order of 3 relocations in TH05's OP.EXE.
2014-08-31 18:08:50 +02:00
nmlgc 6c3cfa94ae [Reduction] #390-391: Sound I/O 2014-08-31 06:27:47 +02:00
nmlgc 00c6ed5f5e [Reduction] #380-383: super_put_rect
[Binary change] db 0 → nop after the end of superptr_draw in all affected
executables.
2014-08-31 04:46:46 +02:00
nmlgc 8571d60085 [Reduction] #375: pfread 2014-08-30 12:50:48 +02:00
nmlgc c39ded4bfa [Reduction] #374: pfrewind
[Binary change] db 0 → nop after the function in TH05's OP.EXE.
2014-08-30 12:33:48 +02:00
nmlgc f5e8062ec0 [Reduction] #373: pfseek 2014-08-30 12:26:02 +02:00
nmlgc b108d5d46f [Reduction] #372: IRand 2014-08-30 12:13:04 +02:00
nmlgc 12c1e8560f [Reduction] #369: file_write 2014-08-30 09:38:09 +02:00
nmlgc 536e17d29e [Reduction] #367-368: file_seek and file_tell 2014-08-30 09:21:44 +02:00
nmlgc 5976ec0458 [Reduction] #366: file_ropen 2014-08-30 09:12:17 +02:00
nmlgc 3ee280b708 [Reduction] #365: file_read 2014-08-30 09:00:31 +02:00
nmlgc 649ab800e1 [Reduction] #364: file_exist 2014-08-30 08:46:38 +02:00
nmlgc 2e814fc3c5 [Reduction] #363: file_create 2014-08-30 08:32:10 +02:00
nmlgc 9a1e030ce7 [Reduction] #361-362: file_flush and file_close 2014-08-30 08:19:17 +02:00
nmlgc 87230af28f [Reduction] #360: file_append 2014-08-30 07:58:36 +02:00
nmlgc 605f044854 [Reduction] #359: File-related global data 2014-08-30 07:49:51 +02:00
nmlgc 86ea9b69ac [Reduction] #358: kbhit 2014-08-30 06:23:45 +02:00
nmlgc 04b1fd3bcc [Reduction] #355-356: ctor2.asm
OK, looks like we got all of the C++ crap out of the way... e~xcept for
another function in TH01's REIIDEN.EXE, of course.

[Binary change] Order of 2 relocations in TH01's FUUIN.EXE.
2014-08-30 03:50:38 +02:00
nmlgc 73af48ac95 [Reduction] #352-354: ctor3.asm 2014-08-30 02:37:53 +02:00
nmlgc be740fc368 [Reduction] #331-351: strings.cpp
God, this C++ stuff really is a crappy mess. Even had to manually adjust the
alignments at the end of the the TEXTC segment - and no, the ALIGN directive
remains an inadequate tool random bytes, even more so because TASM's
implementation just pads the space with random bytes. But hey, nice to finally
see some reduction outside of seg000.

[Binary change]
* Order of 3 relocations in all of TH04 and TH05's OP.EXE
* Order of 6 relocations in TH03's OP.EXE and MAIN.EXE, and TH05's MAIN.EXE
  and MAINE.EXE
* Order of 9 relocations in all of TH01, TH02's OP.EXE and MAINE.EXE, and
  TH03's MAINL.EXE
* Order of 11 relocations in TH02's MAINE.EXE
2014-08-29 12:47:43 +02:00
nmlgc 588ed7b90b [Reduction] #324-330: new.cpp
[Binary change]
* Order of 2 relocations in all executables of TH02, TH03, TH04 and TH05
* Order of 4 relocations in TH01's FUUIN.EXE
* Inserts a new relocation into TH01's REIIDEN.EXE
2014-08-29 10:50:30 +02:00
nmlgc d49fdce731 [Reduction] #274-323: xx.cpp
Yup. 50 functions in a single module, totalling 12,633 bytes, used in all 15
game executables, and no references to any of that in the remaining game code.

[Binary change]
* Order of 3 relocations in all of THO3, TH04 and TH05, TH02's MAIN.EXE and
  MAINE.EXE, and TH01's OP.EXE and FUUIN.EXE
* Order of 2 relocations in TH02's OP.EXE and TH01's REIIDEN.EXE
* Inserts a new relocation into TH03's MAIN.EXE
2014-08-29 08:03:21 +02:00
nmlgc e2ca057d4b [Reduction] #273: cputype.asm
Don't have the source code for that one either.
2014-08-29 05:58:32 +02:00
nmlgc dd400d7627 [Reduction] #268-272: xmsg.cpp
[Binary change] Order of 6 relocations in every executable except for the TH04
ones.
2014-08-29 04:02:38 +02:00
nmlgc e0762650c6 [Reduction] #264-267: xalloc.cpp 2014-08-29 03:24:39 +02:00
nmlgc e1d78d0e9a [Reduction] #260-263: xxas.cpp
Well. Even after downloading pretty much every (identical) copy of Turbo /
Borland C++ 3, 4, 5 and everything inbetween, I could *not* find the original
source to most of the C++ parts in the runtime. Using the IDA disassemblies
to build their slices is simply the only option.

... Really, though, who cares.
2014-08-29 03:08:23 +02:00
nmlgc a9918e364e [Reduction] #259: C++ delete[] operator
Same for registerbgifont() being a wrapper around registerfarbgifont(). But
at least there, IDA should have noticed something weird. The original delete[]
operator refers to the delete function, so registerbgifont() would have had to
be a wrapper around registerbgidriver(), which of course doesn't make sense,
and IDA claims to *know* these functions...
2014-08-29 01:35:20 +02:00
nmlgc 0493c0c4e4 [Reduction] #258: C++ delete operator
Lol, "registerbgidriver". Just because the original function is nothing but a
wrapper around free(), and registerbgidriver() is also just a wrapper around
registerfarbgidriver().
2014-08-29 01:26:20 +02:00
nmlgc 6ebf0877f7 [Reduction] #257: xfflush 2014-08-28 21:54:04 +02:00
nmlgc 0c8e9d8550 [Reduction] #252: 16-bit sine and cosine table
Nice! It's not used by master.lib itself, but ZUN makes good use of these
tables to avoid having to rely on floating-point functions.
2014-08-28 07:54:38 +02:00
nmlgc 55629eecb0 [Reduction] #234-239: super_put
[Binary change] Order of 3 relocations in TH05's OP.EXE, and 2 relocations in
TH05's MAINE.EXE.
2014-08-28 02:23:54 +02:00
nmlgc 68359542c1 [Reduction] #233: Byte mask 2014-08-28 01:37:48 +02:00
nmlgc 2cf62174c0 [Reduction] #232: graph_start 2014-08-28 01:16:54 +02:00
nmlgc 9b3e42a150 [Reduction] #230: graph_400line 2014-08-28 00:58:40 +02:00
nmlgc 057c665ece [Reduction] #229: grcg_vline 2014-08-28 00:48:06 +02:00
nmlgc 0dad2dffc8 [Reduction] #228: grcg_hline 2014-08-28 00:17:57 +02:00
nmlgc 523da7f7b9 [Reduction] #227: Edge pattern table 2014-08-28 00:05:06 +02:00
nmlgc b6872319c4 [Reduction] #226: grcg_byteboxfill_x 2014-08-28 00:04:27 +02:00
nmlgc 877fbd8bd6 [Reduction] #225: Clipping variables for drawing
Well, great. Why did the trapezoid variables have to be included in this
object file? 10 of the executables don't use them, and there's no way to
locate that one needle in the haystack of uninitialized data now.
2014-08-28 00:04:26 +02:00
nmlgc 5a05e580e5 [Reduction] #223-224: memmove 2014-08-27 19:47:14 +02:00
nmlgc f3e9147459 [Reduction] #221-222: memset
Two functions, just differing in their order of parameters. It's...
convenient, I guess?
2014-08-27 07:50:37 +02:00
nmlgc 444901acb5 [Reduction] #220: memcpy 2014-08-27 07:15:15 +02:00
nmlgc 39bf07ac61 [Reduction] #219: memcmp 2014-08-27 07:05:29 +02:00
nmlgc 4f075e1718 [Reduction] #217-218: grcg_setcolor and grcg_off 2014-08-27 07:05:16 +02:00
nmlgc aa9ea36277 [Reduction] #215-216: graph_copy_page 2014-08-27 06:13:48 +02:00
nmlgc a28cd273c4 [Reduction] #214: graph_clear 2014-08-27 06:03:08 +02:00
nmlgc 199138182a [Reduction] #213: Graphic VRAM-related global data
Nothing in the BSS segment for once! Yay.
2014-08-27 05:45:01 +02:00
nmlgc 967a8e3aa5 [Reduction] #212: graph_show
ReC98, where a function consisting of 3 instructions still saves over 150
lines.
2014-08-27 05:19:11 +02:00
nmlgc a4de9710bd [Reduction] #211: make_linework 2014-08-27 05:05:30 +02:00
nmlgc 7240b80154 [Reduction] #209: pfclose 2014-08-27 03:11:13 +02:00
nmlgc 27693992d9 [Reduction] #208: bopenr
Had to explicitly specify "byte ptr pferrno" for binary compatibility...
2014-08-27 02:54:57 +02:00
nmlgc 64609699ef [Reduction] #207: PAR-related global data 2014-08-27 02:40:09 +02:00
nmlgc beae93b603 [Reduction] #204: palette_black_out 2014-08-27 00:33:43 +02:00
nmlgc 8b6d81a3de [Reduction] #203: palette_black_in 2014-08-27 00:26:46 +02:00
nmlgc 80cbfb1dd8 [Reduction] #202: vsync_wait 2014-08-27 00:11:29 +02:00
nmlgc 94c5a12100 [Reduction] #198-201: vsync_start and vsync_end 2014-08-26 23:58:08 +02:00
nmlgc 287d7ea554 [Reduction] #197: VSync-related global data
[Binary change] nop → db 0 after the data declarations in every affected
executable.
2014-08-26 22:52:26 +02:00
nmlgc 1f804283f8 [Reduction] #196: bseek_
With underscore. Seek origin as a separate parameter.
I'm... sure there is a reason?
2014-08-26 22:15:00 +02:00
nmlgc ed6c5e3067 [Reduction] #195: bseek
Without underscore. Relative seek.
2014-08-26 22:04:11 +02:00
nmlgc fae5f003ad [Reduction] #193: bread
This function doesn't seem to be used outside pfopen(), and IDA struggles with
that function, which explains the missing references.
2014-08-26 21:34:06 +02:00
nmlgc 5d2d4feca0 [Reduction] #192: bgetc 2014-08-26 21:23:54 +02:00
nmlgc 40de176f2c [Reduction] #191: bcloser 2014-08-26 20:54:57 +02:00
nmlgc 777a718390 [Reduction] #189-190: bgm_init and bgm_finish
And that's all the games seem to use from the master.lib BGM module.
2014-08-26 07:58:33 +02:00
nmlgc b134176731 [Reduction] #187-188: bgm_timer_init and bgm_timer_finish
[Binary change] Order of 2 relocations in TH04's MAINE.EXE and TH05's OP.EXE
and MAINE.EXE.
2014-08-26 07:39:57 +02:00
nmlgc 54ceaad556 [Reduction] #184-186: RTC interrupt manager 2014-08-26 07:25:43 +02:00
nmlgc 0bb3f897e0 [Reduction] #183: bgm_timerhook 2014-08-26 06:18:06 +02:00