Commit Graph

257 Commits

Author SHA1 Message Date
nmlgc b7aa7291db [Reduction] #182: bgm_read_sdata
[Binary change] Order of 2 relocations in all modified executables.
2014-08-26 06:07:19 +02:00
nmlgc 17fa89801b [Reduction] #181: bgm_sound 2014-08-26 01:51:57 +02:00
nmlgc fab08f2923 [Reduction] #180: bgm_stop_sound 2014-08-26 01:41:08 +02:00
nmlgc 8b7313010e [Reduction] #179: bgm_stop_play 2014-08-26 00:40:14 +02:00
nmlgc 1520dea475 [Reduction] #178: bgm_effect_sound 2014-08-26 00:34:16 +02:00
nmlgc 06d0171bad [Reduction] #176-177: bgm_play
[Binary change] Order of 3 relocations in TH04's MAINE.EXE and TH05's OP.EXE
and MAINE.EXE.
2014-08-26 00:25:48 +02:00
nmlgc d0be24acea [Reduction] #175: bgm_pinit 2014-08-26 00:01:58 +02:00
nmlgc 8416cc93c9 [Reduction] #174: bgm_mget 2014-08-25 23:08:17 +02:00
nmlgc 69daab38b2 [Reduction] #173: bgm_set_tempo 2014-08-25 22:58:39 +02:00
nmlgc 509d3b31b9 [Reduction] #172: BGM-related internal data
Initializing the BSS data to 0 instead of the ? in the original source file
avoids size changes in the MZ header.

[Binary change] Order of 5 relocations in TH04's and TH05's MAIN.EXE.
2014-08-25 22:35:22 +02:00
nmlgc 674ecce1c3 [Reduction] #171: _bgm_bell_org
[Binary change] db 0 → nop before the function in every affected executable.
2014-08-25 04:49:19 +02:00
nmlgc 54c9abefee [Reduction] #160: getdcwd 2014-08-23 18:42:30 +02:00
nmlgc 4a36dd15de [Reduction] #159: super_entry_bfnt
[Binary change] Order of 5 relocations in TH05's MAIN.EXE.
2014-08-23 18:09:23 +02:00
nmlgc 656f993e8d [Reduction] #158: bfnt_palette_set 2014-08-23 16:56:01 +02:00
nmlgc 6e6293be79 [Reduction] #157: palette_init 2014-08-23 16:18:30 +02:00
nmlgc e76a9948b8 [Reduction] #156: palette_show 2014-08-23 16:11:16 +02:00
nmlgc 61ccf52f3e [Reduction] #155: Palette data 2014-08-23 15:47:05 +02:00
nmlgc 138fcd2fce [Reduction] #153-154: Key beep control 2014-08-23 14:01:53 +02:00
nmlgc 4759e85765 [Reduction] #152: js_end
Popcorn.
2014-08-23 13:46:31 +02:00
nmlgc 6114c2871c [Reduction] #151: bfnt_extend_header_analysis
And here we have another TASM limitation: INCLUDE file names apparently are
strcpy()'d to a buffer with a fixed size of 32 bytes, causing a crash when
trying to include any file with a longer name. Quality.
2014-08-23 13:18:32 +02:00
nmlgc 7046c47d28 [Reduction] #149: bfnt_header_read 2014-08-23 12:08:48 +02:00
nmlgc 56a45d0b1d [Reduction] #148: bfnt_entry_pat 2014-08-23 11:51:14 +02:00
nmlgc c718cc159a [Reduction] #147: 4-bit VRAM pixel rotation table
[Binary change] Order of three relocations in TH05's OP.EXE and MAINE.EXE.
2014-08-23 03:16:07 +02:00
nmlgc 76139a57c8 [Reduction] #146: dos_axdx 2014-08-23 03:03:17 +02:00
nmlgc cd1d7b341e [Reduction] #145: dos_keyclear 2014-08-23 03:02:18 +02:00
nmlgc 4d3b735008 [Reduction] #144: dos_puts2 2014-08-23 01:48:16 +02:00
nmlgc 50bd48da18 [Reduction] #143: dos_setvect 2014-08-23 01:38:22 +02:00
nmlgc a756bab3cc [Reduction] #142: dos_read 2014-08-23 01:07:04 +02:00
nmlgc 4bcebcd875 [Reduction] #141: dos_seek 2014-08-23 00:59:10 +02:00
nmlgc ba3e077fc8 [Reduction] #140: dos_close 2014-08-23 00:48:48 +02:00
nmlgc 2e2151b592 [Reduction] #139: super_entry_pat
Heh, all the references to this function are still expressed in db opcode
form, because IDA couldn't process the self-modifying code in
bfnt_entry_pat(). That's almost practical in our case!
2014-08-23 00:28:05 +02:00
nmlgc 4e6ef3bd8d [Reduction] #138: super_entry_at 2014-08-22 23:56:33 +02:00
nmlgc 857c443b57 [Reduction] #137: super_free
... yeah, TH02's MAINE.EXE indeed seems to not free its superimposed data.
In case it even allocates any.

[Binary change] db 0 → nop in ZUNSOFT.COM.
2014-08-22 23:45:21 +02:00
nmlgc 22112eab6a [Reduction] #136: super_cancel_pat 2014-08-22 23:33:18 +02:00
nmlgc 587f109e6a [Reduction] #135: Superimposed pattern data
... It really shows that I forgot to compress the "db 0" statements in
2bd664c5e4.
2014-08-22 22:31:44 +02:00
nmlgc 8b32104540 [Reduction] #131-134: graph_pi_load_pack
Second biggest master.lib object right there... and apparently, TASM doesn't
support segment prefixes in EQU directives?

And yes, there really is no viable solution for both the NOPCALL problem (the
TASM manual states that these NOPs are inserted during single-pass assembly,
which we can't do) and the complementary jump sequences (which are only
inserted for forward references when specifying the JUMPS directive, which
doesn't seem to work for us either).
2014-08-22 21:15:44 +02:00
nmlgc 193ca02550 [Reduction] #130: ___write
Doing one of these C monstrosities a day seems like a good habit. And hey,
ZUNSOFT.COM has already shrunk by over a third.
2014-08-22 19:28:05 +02:00
nmlgc 4e9ad18af1 Move common directives and includes to a separate include file
Note that .386 needs to come before .MODEL, and is therefore not included in
ReC98.inc. Causes, um, weird label errors otherwise.
2014-08-22 18:01:06 +02:00
nmlgc 2d1dc1589c [Reduction] #128-129: __rtl_write and __write
Underscores and wrappers, hooray.
__write is not included in the widely available version of WRITEA.CAS, but
it's still part of the same object file.
2014-08-22 02:55:11 +02:00
nmlgc 216413d8a6 [Reduction] #127: lseek
Yup, gotta move all the "handle" definitions away first.
2014-08-22 01:55:05 +02:00
nmlgc aaa2d23fc8 [Reduction] #126: graph_pi_free
Huh, the compatibility NOPs extend to master.lib as well?
2014-08-22 01:39:42 +02:00
nmlgc c3202f4450 [Reduction] #125: hmem_lallocate 2014-08-22 01:19:52 +02:00
nmlgc 47781cd013 [Reduction] #124: smem_wget 2014-08-22 01:04:46 +02:00
nmlgc 7cde3a50ec [Reduction] #123: smem_release
Need to do this function before smem_wget() to keep the alignment identical.
2014-08-22 00:59:18 +02:00
nmlgc ea4db822ab [Reduction] #120-122: Heap memory functions
With even more misreferences in switch tables.
2014-08-22 00:17:53 +02:00
nmlgc 969990a819 [Reduction] #119: mem_assign_dos
Containing, again, fixes for misreferences in TH04.
2014-08-21 23:30:20 +02:00
nmlgc fc0ccd5e2b [Reduction] #117-118: mem_assign and mem_assign_all 2014-08-21 23:05:54 +02:00
nmlgc d270a625e5 [Reduction] #116: master.lib memory manager variables 2014-08-21 22:54:07 +02:00
nmlgc 99b9963082 [Reduction] #115: dos_ropen
AKA "fontfile_open()", and originally kept in FONTOPEN.ASM... yeah.
2014-08-21 22:09:18 +02:00
nmlgc 8e4683cd1e [Reduction] #109-113: Signal handling
> "OK, the signal slice is pretty large, let's do it tomorrow"
> stay there for the majority of the day

Oh well, at least it paid off. I *really* should work towards PI loading now,
though.
2014-08-21 21:28:18 +02:00
nmlgc d1ccecdfa9 [Reduction] #106-108: PC-98 EGC setup
"Enhanced Graphic Charger", hm...
2014-08-20 22:24:05 +02:00
nmlgc a244c30cd9 [Reduction] #104-105: _dos_getdrive and _dos_setdrive 2014-08-20 21:38:31 +02:00
nmlgc 69672b819a [Reduction] #103: DOSENV 2014-08-20 21:22:56 +02:00
nmlgc 8ca6964330 [Reduction] #102: ErrorMessage 2014-08-20 20:38:08 +02:00
nmlgc e6e1e3a937 [Reduction] #101: Far struct copy 2014-08-20 20:35:18 +02:00
nmlgc 68e1dc8596 [Reduction] #100: fflush 2014-08-20 19:46:47 +02:00
nmlgc 33fa958a30 [Reduction] #98-99: getvect and setvect
Yeah, getvect.asm also includes setvect(). They really could have chosen a
better naming scheme.
2014-08-20 18:09:26 +02:00
nmlgc ea547e4841 [Reduction] #92-97: exit 2014-08-20 17:53:02 +02:00
nmlgc 9d23be1a92 [Reduction] #91: stpcpy 2014-08-20 17:03:08 +02:00
nmlgc d3aaca7bd3 [Reduction] #90: text_clear 2014-08-20 16:45:24 +02:00
nmlgc eff96385b0 [Reduction] #82-89: PC-98 escape sequences
I don't know anything about ANSI/VT100/??? escape sequences, but after some
quick research, these sequences and their effect seem to be specific to the
PC-98 (although they're implemented as part of DOS, of course).
2014-08-20 16:27:28 +02:00
nmlgc 8f6c28c939 Restore master.lib's FUNC and ENDFUNC macros
With seg000 changed to word alignment and all definitions for "func" removed,
the master.lib functions can keep their exact alignment themselves.

[Binary change] db 0 → nop before get_machine_98() in the MAIN.EXE and
MAINE.EXE files of TH04 and TH05, respectively.
2014-08-20 15:25:40 +02:00
nmlgc b90a1e2320 [Reduction] #80: chmod
Yup, getting rid of all the definitions for "func", so that we can restore the
master.lib macro with the same name.
2014-08-20 14:02:29 +02:00
nmlgc e9701c491d [Reduction] #79: atexit
Once again, random misreferences in one executable slow down the development.
And that function doesn't even seem to be called anywhere.
2014-08-20 14:02:27 +02:00
nmlgc ce00b0b534 [Reduction] #70-78: C start up code
Finally!

[Binary change] Order of the first three relocations in every executable.
Two more relocations in the TH01 executables.
2014-08-20 14:02:26 +02:00
nmlgc 8082ba0434 [Reduction] #52: setupio
Thanks, ZUNSOFT.COM, for turning this function into a mess.

[Binary change] Two relocations in every executable... *except* for TH01's
REIIDEN.EXE.
2014-08-18 19:50:20 +02:00
nmlgc dcb2726799 [Reduction] #51: Standard FILE structures
[Binary change] Relocations in TH01's FUUIN.EXE. (...)
2014-08-18 16:58:24 +02:00
nmlgc 11a91d0e45 [Reduction] #50: setenvp 2014-08-18 14:33:24 +02:00
nmlgc c5860dd7a6 Set up labels to denote the BSS and init/exit table segments
Again, we can't split dseg into the "real" segments just yet, because that
would force us to correct the assumed data segment in every single function.

[Binary change] Relocations in TH01's FUUIN.EXE. Again.
2014-08-17 23:55:59 +02:00
nmlgc aaba4d6149 Fix the declaration of errno
Hooray for underscore confusion. Should have copy-pasted the correct one all
along...
2014-08-17 13:57:24 +02:00
nmlgc 5fb4445ada [Reduction] #48-49: exec
[Binary change] Relocations in TH01's FUUIN.EXE.
2014-08-17 13:57:03 +02:00
nmlgc d4b766ee4e [Reduction] #45-47: Far data segment space allocation 2014-08-15 21:48:43 +02:00
nmlgc a033b347fc [Reduction] #44: graph_extmode 2014-08-15 16:12:09 +02:00
nmlgc a313ae5d78 [Reduction] #43: Text VRAM variables 2014-08-15 14:26:44 +02:00
nmlgc 554d0325d5 [Reduction] #41: Long pointer comparison 2014-08-14 20:07:00 +02:00
nmlgc 859e48a59f [Reduction] #40: Long multiplication 2014-08-14 20:06:58 +02:00
nmlgc ca18919ee7 [Reduction] #38: Long division 2014-08-14 20:06:55 +02:00
nmlgc bf4edcec28 [Reduction] #37: Long shift left 2014-08-14 20:06:54 +02:00
nmlgc fc9dacd180 [Reduction] #36: Huge pointer addition 2014-08-14 19:55:26 +02:00
nmlgc 3b911b3c20 [Reduction] #35: _isatty 2014-08-14 19:55:23 +02:00
nmlgc 4e3bd76348 [Reduction] #33-34: __IOERROR and __DOSERROR 2014-08-14 15:56:57 +02:00
nmlgc d95fc3cdd9 [Reduction] #32: get_machine 2014-08-14 14:48:55 +02:00
nmlgc 7b9a30fc8d [Reduction] #31: get_machine_98 2014-08-14 14:30:48 +02:00
nmlgc 1c91cc75e7 [Reduction] #30: get_machine_at
Um. Not sure if ZUN used an older version there, or if these additional
branches simply resulted from a lack of optimization...
And I even had to convert the labels to local syntax.
2014-08-14 14:27:36 +02:00
nmlgc af609d5e1c [Reduction] #29: get_machine_dosbox 2014-08-14 13:22:17 +02:00
nmlgc 59688e23fc [Reduction] #28: Machine_State
We~ll, OK, it's just a single variable, but it's originally stored in its own
.ASM file as well.
And yup, that's how we're going to treat data slices.
2014-08-14 13:22:14 +02:00
nmlgc cc313d5095 [Reduction] #27: check_machine_fmr 2014-08-14 12:22:50 +02:00
nmlgc 5764275549 [Reduction] #26: strrchr
Marking the first function that was originally written in C, which means that
there are no original label names we could preserve.
2014-08-14 12:22:44 +02:00
nmlgc a3ab75cd34 [Reduction] #25: _strcat 2014-08-14 12:22:37 +02:00
nmlgc adf8e137d9 [Reduction] #24: _strcmp
[Binary change] Relocation order in TH01's REIIDEN.EXE... do they depend on
some kind of RNG?
2014-08-14 12:22:31 +02:00
nmlgc 18f77cb7da Include RULES.ASI from every executable's dump file.
Having thought this over for a while, I've decided to stay with the "include
slice" model for now, due to various bugs and other reasons.

We need to compile for the 386 CPU, but this causes TASM to automatically
default every segment to 32-bit mode, which of course is not what we want (and
no, .MODEL USE16 sadly does not help either). Appending USE16 to every segment
declaration in all included files seems to work, but for some reason, this
messes up certain jump instructions. WTF? And even if it did work, we would
still have to do this for every single file we include.

The alternative would be to build proper libraries and let the linker merge
all the code. This would add a lot of unwarranted complexity to the build
process. Not to mention all the EXTERN statements we'd have to maintain.

Ultimately, all of the C runtime ASM code is going to vanish anyway once we've
completed the reduction step. Once we're there, we can simply link to the
original version of the library. These initial dumps are not pretty, and I see
no point in wasting time on making intermediary stages of development look
pretty.

Since including RULES.ASI from every slice seems a bit inefficient (and even
potentiall harmful, considering the age of the development tools we have to
work with), we'll only include it once at the top of every main dump file.

[Binary change] Relocations in TH01's REIIDEN.EXE, again.
2014-08-14 09:54:00 +02:00
nmlgc 43f280ab55 [Reduction] #6-18: Far heap functions
Wow, what a slice. Lots of code, and it comes with its own data declarations
inside the code segment! Since all these functions were originally contained
in one code file, it makes sense to do all 13 in one commit. This removes all
erroneous references to the 'NULL CHECK' string.

[Binary change] This also changes some relocations in TH01's REIIDEN.EXE.
2014-08-13 14:40:41 +02:00
nmlgc 534ba2d142 [Reduction] #5: bfill
To get anywhere, we must become able to include assembly files that define
their own segments. But this will only work if we include these files in the
order they appear in in our dumps, *starting from the very first one*. And to
include the very first one, we must first get rid of the erroneous references
to the first few bytes of the data segment... and this function happens to be
the first one referencing those.
2014-08-10 11:47:36 +02:00
nmlgc 130a5c587d [Reduction] #4: _strcpy 2014-08-10 07:52:56 +02:00
nmlgc 23674951e5 [Reduction] #3: _stricmp 2014-08-10 07:52:29 +02:00
nmlgc 4dba5673cb [Reduction] #2: _strlen
Yes, I do have the .CAS files. However, even though they contain the assembly
source, they're actually C source, and we're not that far yet.
2014-08-10 07:51:36 +02:00
nmlgc 713ad758b6 [Reduction] #1: __abort
It begins. And this already shows that the inclusion of TH01's ZUNSOFT.COM
will double the size of all Borland C routines we slice out, because we have
to cover both large and tiny memory models...
2014-08-10 07:50:38 +02:00
nmlgc 60cf35edad Remove IDA's cross reference comments
We're going to rename *everything*, and grep is a much more useful tool to
achieve the same.
2014-08-10 07:40:12 +02:00
nmlgc 2bd664c5e4 Compress unitialized memory by replacing bytes with dwords 2014-07-05 23:08:34 +02:00
nmlgc 174e08fc60 th05: Fix all remaining alignment errors
These stray NOPs and "db 0" declarations were exactly what made the recompiled
executables comparatively large.
2014-07-05 22:29:58 +02:00
nmlgc 0ff83ca74e th05/op: Identify menu description strings 2014-07-04 15:00:44 +02:00
nmlgc 4eceb05d9d th05/op: Identify sound setup strings
More relocation changes?
2014-07-04 14:55:07 +02:00
nmlgc 5a1b691f21 th05/op: Identify Music Room strings 2014-07-04 14:50:35 +02:00
nmlgc 53fa9b1cfb th05/op: Declare some missing strings as such
Well, nobody actually creates perfect code the first time around, except
Linus Torvalds. (http://youtu.be/4XpnKHJAok8?t=22m18s)
2014-07-04 14:42:38 +02:00
nmlgc 91cb632353 th05/op: Additional alignment fixes
Now, we're fully identical to the original build - save for three instructions
that are getting assembled using different, but equivalent opcodes.
2014-06-28 20:38:31 +02:00
nmlgc 224f92c77f th05/op: Remove the duplicate segment alignment parameter for seg000 2014-06-28 20:38:30 +02:00
nmlgc 9e07c54aee Start out with th05's OP.EXE
This is the raw output of IDA's initial analysis of the original OP.EXE,
touched up in order to compile to an executable identical to the original
build.
2014-06-26 22:47:15 +02:00