From fd6a8bae81aaef8736ce4b4a6e898a0dca99d1bb Mon Sep 17 00:00:00 2001 From: nmlgc Date: Tue, 3 Mar 2020 19:41:02 +0100 Subject: [PATCH] [Decompilation] [th01] .GRZ file loading and display Yet another run-length encoded graphics format, this one being exclusively used to wastefully store Konngara's sword slash and kuji-in kill "animation". But for once, the terrible code generated by inline functions with non-literal parameters perfectly matches what ZUN wrote here. Part of P0081, funded by Ember2528. --- Makefile.mak | 4 +- th01/formats/grz.cpp | 245 ++++++++ th01/formats/grz.h | 59 ++ th01/formats/grz[bss].asm | 7 + th01/formats/grz[data].asm | 5 + th01/main_08.cpp | 6 + th01/op_09.cpp | 6 + th01_op.asm | 1056 +-------------------------------- th01_reiiden.asm | 1128 +----------------------------------- th01_reiiden_2.inc | 175 ++---- 10 files changed, 377 insertions(+), 2314 deletions(-) create mode 100644 th01/formats/grz.cpp create mode 100644 th01/formats/grz.h create mode 100644 th01/formats/grz[bss].asm create mode 100644 th01/formats/grz[data].asm create mode 100644 th01/main_08.cpp create mode 100644 th01/op_09.cpp diff --git a/Makefile.mak b/Makefile.mak index 342354bf..25706b6b 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -41,12 +41,12 @@ th05:: $(TH05:\=bin\th05\) bin\th01\zunsoft.com: th01\zunsoft.c $(CC) $(CFLAGS) -mt -lt -nbin\th01\ $** masters.lib -bin\th01\op.exe: bin\th01\op.obj th01\op_02.c th01\op_03.c th01\op_04.c th01\op_05.c th01\op_06.cpp th01\op_08.c th01\op_10.c th01\op_11.c th01\op_12.cpp +bin\th01\op.exe: bin\th01\op.obj th01\op_02.c th01\op_03.c th01\op_04.c th01\op_05.c th01\op_06.cpp th01\op_08.c th01\op_09.cpp th01\op_10.c th01\op_11.c th01\op_12.cpp $(CC) $(CFLAGS) -ml -3 -DGAME=1 -nbin\th01\ -eOP.EXE @&&| $** | -bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c +bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_02.c th01\main_03.c th01\main_04.c th01\main_05.c th01\main_06.cpp th01\main_08.cpp th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c $(CC) $(CFLAGS) -ml -3 -DGAME=1 -nbin\th01\ -eREIIDEN.EXE @&&| $** | diff --git a/th01/formats/grz.cpp b/th01/formats/grz.cpp new file mode 100644 index 00000000..978fc77d --- /dev/null +++ b/th01/formats/grz.cpp @@ -0,0 +1,245 @@ +#pragma option -Z + +extern "C" { + +#include +#include + +#include +#include "ReC98.h" +#include "th01/hardware/graph.h" +#include "th01/formats/grz.h" + +extern const char HGRZ_MAGIC[4]; +extern const char HGRX_MAGIC[4]; + +extern char planar_stream_id; +extern char grx_col; +extern uint8_t* rle_streams[GRX_COUNT]; +// Actually a planar8_t*, but used like a dots8_t* everywhere. +extern dots8_t* planar_streams[GRX_COUNT][PLANAR_STREAM_PER_GRX_COUNT]; +extern unsigned char planar_stream_count[GRX_COUNT]; + +struct grz_header_t { + char magic[sizeof(HGRZ_MAGIC)]; + uint8_t image_count; + int8_t padding[3]; + int32_t offsets[GRZ_IMAGE_COUNT]; + int32_t total_size; // including this header + int8_t unknown[20]; +}; + +struct grx_header_t { + char magic[sizeof(HGRX_MAGIC)]; + uint8_t planar_stream_count; + int8_t unused_1[3]; + uint16_t rle_stream_size; + uint16_t planar_stream_size; + int8_t unused_2[52]; +}; + +void grx_put_stream(unsigned int slot, int planar_stream) +{ + if(planar_stream_count[slot] > planar_stream) { + planar_stream_id = planar_stream; + grx_put(slot); + planar_stream_id = 0; + } +} + +void grx_put_col(unsigned int slot, uint4_t col) +{ + grx_col = (col + 1); + grx_put(slot); + grx_col = 0; +} + +inline void vram_put(seg_t segment, uint16_t offset, dots8_t dots) +{ + *reinterpret_cast(MK_FP(segment, offset)) = dots; +} + +void grx_put(unsigned int slot) +{ + uint8_t command; + uint8_t runs; + uint8_t *rle = rle_streams[slot]; + dots8_t *planar = planar_streams[slot][planar_stream_id]; + +#define put(vram_offset, vram_offset_last, planar) \ + if(!grx_col) { \ + vram_put(SEG_PLANE_B, vram_offset, *(planar++)); \ + vram_put(SEG_PLANE_R, vram_offset, *(planar++)); \ + vram_put(SEG_PLANE_G, vram_offset, *(planar++)); \ + vram_put(SEG_PLANE_E, vram_offset_last, *(planar++)); \ + } else { \ + vram_put(SEG_PLANE_B, vram_offset_last, 0xFF); \ + } + + if(grx_col) { + grcg_setcolor_rmw(grx_col - 1); + } + for(uint16_t vram_offset = 0; vram_offset < PLANE_SIZE; vram_offset++) { + command = *(rle++); + if(command == GC_RUN) { + runs = *(rle++); + if(runs) { + command = *(rle++); + while(runs--) { + if(command == GC_PUT) { + put(vram_offset, vram_offset++, planar); + } else { + vram_offset++; + } + } + } + } + // Yes, in case we just did a putting GC_RUN, we are in fact putting + // one more byte! + if(command == GC_PUT) { + put(vram_offset, vram_offset, planar); + } + } + if(grx_col) { + grcg_off(); + } +#undef put +} + +/// Loading and freeing +/// ------------------- +#define fail_if(cond) \ + if(cond) { \ + file_close(); \ + return 1; \ + } + +#define grx_header_read(grx, slot) \ + file_read(&grx, sizeof(grx)); \ + fail_if(memcmp(grx.magic, HGRX_MAGIC, sizeof(HGRX_MAGIC))); \ + fail_if(grx.planar_stream_count < 1); \ + planar_stream_count[slot] = grx.planar_stream_count; \ + +#define rle_stream_new(slot, size) \ + if(rle_streams[slot]) { \ + grx_free(slot); \ + } \ + fail_if((rle_streams[slot] = new uint8_t[size]) == NULL); + +#define rle_stream_read(slot, size) \ + file_read(rle_streams[slot], size); + +#define planar_streams_new(slot, stream_count, size) \ + for(i = 0; i < stream_count; i++) { \ + if(planar_streams[slot][i]) { \ + grx_free(slot); \ + } \ + fail_if((planar_streams[slot][i] = new uint8_t[size]) == NULL); \ + } + +#define planar_streams_read(slot, stream_count, size) \ + for(i = 0; i < stream_count; i++) { \ + file_read(planar_streams[slot][i], size); \ + } + +union headers_t { + grz_header_t grz; + grx_header_t grx; + int8_t space[100]; +}; + +int grx_load(unsigned int slot, const char *fn) +{ + uint16_t rle_size; + uint16_t planar_size; + + if(!file_ropen(fn)) { + return 1; + } + headers_t* h = new headers_t[1]; + grx_header_read(h->grx, slot); + + rle_size = h->grx.rle_stream_size; + planar_size = h->grx.planar_stream_size; + + int i; + rle_stream_new(slot, rle_size); + planar_streams_new(slot, h->grx.planar_stream_count, planar_size); + + rle_stream_read(slot, rle_size); + planar_streams_read(slot, h->grx.planar_stream_count, planar_size); + delete[] h; + file_close(); + return 0; +} + +int grx_load_noplanar(unsigned int slot, const char *fn) +{ + uint16_t rle_size; + + if(!file_ropen(fn)) { + return 1; + } + headers_t* h = new headers_t[1]; + grx_header_read(h->grx, slot); + rle_size = h->grx.rle_stream_size; + + rle_stream_new(slot, rle_size); + rle_stream_read(slot, rle_size); + delete[] h; + file_close(); + return 0; +} + +void grx_free(unsigned int slot) +{ + if(rle_streams[slot]) { + delete[] rle_streams[slot]; + rle_streams[slot] = NULL; + } + for(int i = 0; i < PLANAR_STREAM_PER_GRX_COUNT; i++) { + if(planar_streams[slot][i]) { + delete[] planar_streams[slot][i]; + planar_streams[slot][i] = NULL; + } + } +} + +int grz_load_single(unsigned int slot, const char *fn, int n) +{ + register int i; + uint16_t rle_size; + uint16_t planar_size; + + if(!file_ropen(fn)) { + return 1; + } + headers_t* h = new headers_t[1]; + + file_read(&h->grz, sizeof(h->grz)); + fail_if(memcmp(h->grz.magic, HGRZ_MAGIC, sizeof(HGRZ_MAGIC))); + + uint8_t image_count = h->grz.image_count; + if(image_count > n) { + // TODO: Srsly? + i = (offsetof(grz_header_t, offsets) + (n * sizeof(int32_t))); + int32_t offset = *reinterpret_cast(&h->space[i]); + file_seek(offset, 0); + + grx_header_read(h->grx, slot); + rle_size = h->grx.rle_stream_size; + planar_size = h->grx.planar_stream_size; + + rle_stream_new(slot, rle_size); + planar_streams_new(slot, h->grx.planar_stream_count, planar_size); + + rle_stream_read(slot, rle_size); + planar_streams_read(slot, h->grx.planar_stream_count, planar_size); + } + delete[] h; + file_close(); + return 0; +} +/// ------------------- + +} diff --git a/th01/formats/grz.h b/th01/formats/grz.h new file mode 100644 index 00000000..e370edfc --- /dev/null +++ b/th01/formats/grz.h @@ -0,0 +1,59 @@ +/// Run-length encoded, 16-color + alpha, 640×400 image format +/// ---------------------------------------------------------- +/// .GRX decouples the RLE command stream from the pixel data. This allows +/// either multiple pixel streams (stored as planar8_t) to be used with the +/// same RLE stream, or the RLE stream to be used on its own for a monochrome +/// byte-aligned pattern. + +// RLE stream format +enum grx_rle_t { + // Puts the next byte from the pixel data source. No parameters. + GC_PUT = 0, + // Followed by: + // * a uint8_t with the length of this run in 8-dot units + // * a uint8_t with the command to use for all runs (0 = put, everything + // else = skip) + GC_RUN = 1, +}; + +// Static arrays +#define GRX_COUNT 16 +#define PLANAR_STREAM_PER_GRX_COUNT 16 + +// File format limit +#define GRZ_IMAGE_COUNT 16 + +// Loading +// ------- +// All of these load the file with the given [fn] into the given [slot], +// automatically freeing any previously loaded image in there, and return 0 +// on success or 1 on failure. + +// Loads the [n]th GRX image, with all of its planar streams, from a .GRZ +// file. +int grz_load_single(unsigned int slot, const char *fn, int n); + +// Loads the given .GRX file, with all of its planar streams. +int grx_load(unsigned int slot, const char *fn); + +// Loads only the RLE stream of the given .GRX file. +int grx_load_noplanar(unsigned int slot, const char *fn); +// ------- + +// Display +// ------- +// Equivalent to grz_put_stream(slot, 0); +void grx_put(unsigned int slot); + +// Displays the planar stream with the given number of the image loaded into +// the given GRX [slot]. +void grx_put_stream(unsigned int slot, int planar_stream); + +// Renders only the RLE stream in the given [col] via the GRCG, using a 0xFF +// pattern for every 8 dots to be displayed. +void grx_put_col(unsigned int slot, uint4_t col); +// ------- + +// Frees both the RLE and any BRGE8 streams in the given GRX [slot]. +void grx_free(unsigned int slot); +/// ---------------------------------------------------------- diff --git a/th01/formats/grz[bss].asm b/th01/formats/grz[bss].asm new file mode 100644 index 00000000..81bdbc64 --- /dev/null +++ b/th01/formats/grz[bss].asm @@ -0,0 +1,7 @@ +GRX_COUNT = 16 +PLANAR_STREAM_PER_GRX_COUNT = 16 + +public _rle_streams, _planar_streams, _planar_stream_count +_rle_streams dd GRX_COUNT dup (?) +_planar_streams dd GRX_COUNT dup (PLANAR_STREAM_PER_GRX_COUNT dup (?)) +_planar_stream_count db GRX_COUNT dup (?) diff --git a/th01/formats/grz[data].asm b/th01/formats/grz[data].asm new file mode 100644 index 00000000..eff8ff07 --- /dev/null +++ b/th01/formats/grz[data].asm @@ -0,0 +1,5 @@ +public _planar_stream_id, _grx_col, _HGRX_MAGIC, _HGRZ_MAGIC +_planar_stream_id db 0 +_grx_col db 0 +_HGRX_MAGIC db 'HGRX',0 +_HGRZ_MAGIC db 'HGRZ',0 diff --git a/th01/main_08.cpp b/th01/main_08.cpp new file mode 100644 index 00000000..6ea61d30 --- /dev/null +++ b/th01/main_08.cpp @@ -0,0 +1,6 @@ +/* ReC98 + * ----- + * Code segment #8 of TH01's REIIDEN.EXE + */ + +#include "th01/formats/grz.cpp" diff --git a/th01/op_09.cpp b/th01/op_09.cpp new file mode 100644 index 00000000..54a752de --- /dev/null +++ b/th01/op_09.cpp @@ -0,0 +1,6 @@ +/* ReC98 + * ----- + * Code segment #9 of TH01's OP.EXE + */ + +#include "th01/formats/grz.cpp" diff --git a/th01_op.asm b/th01_op.asm index 58889efb..fddc7b4f 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -3212,780 +3212,6 @@ arg_0 = dword ptr 6 leave retf sub_DBAF endp - -; --------------------------------------------------------------------------- - push bp - mov bp, sp - push si - mov si, [bp+6] - mov al, [si+18D2h] - mov ah, 0 - cmp ax, [bp+8] - jle short loc_DBFD - mov al, [bp+8] - mov byte_129C8, al - push si - nopcall sub_DC1B - pop cx - mov byte_129C8, 0 - -loc_DBFD: - pop si - pop bp - retf -; --------------------------------------------------------------------------- - push bp - mov bp, sp - mov al, [bp+8] - inc al - mov byte_129C9, al - push word ptr [bp+6] - nopcall sub_DC1B - pop cx - mov byte_129C9, 0 - pop bp - retf - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_DC1B proc far - -var_2E = word ptr -2Eh -var_2C = word ptr -2Ch -var_29 = byte ptr -29h -var_28 = word ptr -28h -var_25 = byte ptr -25h -var_24 = word ptr -24h -var_21 = byte ptr -21h -var_20 = word ptr -20h -var_1D = byte ptr -1Dh -var_1C = word ptr -1Ch -var_1A = word ptr -1Ah -var_17 = byte ptr -17h -var_16 = word ptr -16h -var_13 = byte ptr -13h -var_12 = word ptr -12h -var_F = byte ptr -0Fh -var_E = word ptr -0Eh -var_B = byte ptr -0Bh -var_A = dword ptr -0Ah -var_6 = dword ptr -6 -var_2 = byte ptr -2 -var_1 = byte ptr -1 -arg_0 = word ptr 6 - - enter 2Eh, 0 - push si - push di - mov di, [bp+arg_0] - mov bx, di - shl bx, 2 - mov ax, [bx+1494h] - mov dx, [bx+1492h] - mov word ptr [bp+var_6+2], ax - mov word ptr [bp+var_6], dx - mov bx, di - shl bx, 6 - mov al, byte_129C8 - cbw - shl ax, 2 - add bx, ax - mov ax, [bx+14D4h] - mov dx, [bx+14D2h] - mov word ptr [bp+var_A+2], ax - mov word ptr [bp+var_A], dx - cmp byte_129C9, 0 - jz short loc_DC66 - mov al, byte_129C9 - cbw - dec ax - call _grcg_setcolor_rmw stdcall, ax - pop cx - -loc_DC66: - xor si, si - jmp loc_DDDC -; --------------------------------------------------------------------------- - -loc_DC6B: - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_1], al - inc word ptr [bp+var_6] - cmp [bp+var_1], 1 - jnz loc_DD47 - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_2], al - inc word ptr [bp+var_6] - cmp [bp+var_2], 0 - jz loc_DD47 - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_1], al - inc word ptr [bp+var_6] - jmp loc_DD3B -; --------------------------------------------------------------------------- - -loc_DCA2: - cmp [bp+var_1], 0 - jnz loc_DD3A - cmp byte_129C9, 0 - jnz short loc_DD28 - les bx, [bp+var_A] - mov al, es:[bx] - mov [bp+var_B], al - inc word ptr [bp+var_A] - mov [bp+var_E], si - mov ax, 0A800h - mov bx, [bp+var_E] - mov dl, [bp+var_B] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_F], al - inc word ptr [bp+var_A] - mov [bp+var_12], si - mov ax, 0B000h - mov bx, [bp+var_12] - mov dl, [bp+var_F] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_13], al - inc word ptr [bp+var_A] - mov [bp+var_16], si - mov ax, 0B800h - mov bx, [bp+var_16] - mov dl, [bp+var_13] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_17], al - inc word ptr [bp+var_A] - mov [bp+var_1A], si - inc si - mov ax, 0E000h - mov bx, [bp+var_1A] - mov dl, [bp+var_17] - mov es, ax - assume es:nothing - mov es:[bx], dl - jmp short loc_DD3B -; --------------------------------------------------------------------------- - -loc_DD28: - mov [bp+var_1C], si - inc si - mov ax, 0A800h - mov bx, [bp+var_1C] - mov es, ax - assume es:nothing - mov byte ptr es:[bx], 0FFh - jmp short loc_DD3B -; --------------------------------------------------------------------------- - -loc_DD3A: - inc si - -loc_DD3B: - mov al, [bp+var_2] - dec [bp+var_2] - or al, al - jnz loc_DCA2 - -loc_DD47: - cmp [bp+var_1], 0 - jnz loc_DDDB - cmp byte_129C9, 0 - jnz short loc_DDCC - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_1D], al - inc word ptr [bp+var_A] - mov [bp+var_20], si - mov ax, 0A800h - mov bx, [bp+var_20] - mov dl, [bp+var_1D] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_21], al - inc word ptr [bp+var_A] - mov [bp+var_24], si - mov ax, 0B000h - mov bx, [bp+var_24] - mov dl, [bp+var_21] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_25], al - inc word ptr [bp+var_A] - mov [bp+var_28], si - mov ax, 0B800h - mov bx, [bp+var_28] - mov dl, [bp+var_25] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_29], al - inc word ptr [bp+var_A] - mov [bp+var_2C], si - mov ax, 0E000h - mov bx, [bp+var_2C] - mov dl, [bp+var_29] - mov es, ax - assume es:nothing - mov es:[bx], dl - jmp short loc_DDDB -; --------------------------------------------------------------------------- - -loc_DDCC: - mov [bp+var_2E], si - mov ax, 0A800h - mov bx, [bp+var_2E] - mov es, ax - assume es:nothing - mov byte ptr es:[bx], 0FFh - -loc_DDDB: - inc si - -loc_DDDC: - cmp si, 7D00h - jb loc_DC6B - cmp byte_129C9, 0 - jz short loc_DDF0 - call _grcg_off_func - -loc_DDF0: - pop di - pop si - leave - retf -sub_DC1B endp - -; --------------------------------------------------------------------------- - enter 0Ah, 0 - push si - push di - mov di, [bp+6] - pushd dword ptr [bp+8] - call file_ropen - or ax, ax - jz loc_DEEF - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov [bp-6], dx - mov [bp-8], ax - push dx - push ax - push 40h - call file_read - push 4 - push ds - push offset aHgrx ; "HGRX" - pushd dword ptr [bp-8] - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_DE41 - call file_close - jmp loc_DEEF -; --------------------------------------------------------------------------- - -loc_DE41: - les bx, [bp-8] - assume es:nothing - cmp byte ptr es:[bx+4], 1 - jnb short loc_DE53 - call file_close - jmp loc_DEEF -; --------------------------------------------------------------------------- - -loc_DE53: - les bx, [bp-8] - mov al, es:[bx+4] - mov [di+18D2h], al - mov ax, es:[bx+8] - mov [bp-2], ax - mov ax, es:[bx+0Ah] - mov [bp-4], ax - mov bx, di - shl bx, 2 - mov ax, [bx+1492h] - or ax, [bx+1494h] - jz short loc_DE82 - push di - nopcall sub_E02B - pop cx - -loc_DE82: - push word ptr [bp-2] - call @$bnwa$qui - pop cx - mov bx, di - shl bx, 2 - mov [bx+1494h], dx - mov [bx+1492h], ax - or ax, dx - jnz short loc_DEA3 - call file_close - jmp short loc_DEEF -; --------------------------------------------------------------------------- - -loc_DEA3: - mov word ptr [bp-0Ah], 0 - jmp short loc_DEF7 -; --------------------------------------------------------------------------- - -loc_DEAA: - mov bx, di - shl bx, 6 - mov ax, [bp-0Ah] - shl ax, 2 - add bx, ax - mov ax, [bx+14D2h] - or ax, [bx+14D4h] - jz short loc_DEC8 - push di - nopcall sub_E02B - pop cx - -loc_DEC8: - push word ptr [bp-4] - call @$bnwa$qui - pop cx - mov bx, di - shl bx, 6 - mov si, [bp-0Ah] - shl si, 2 - add bx, si - mov [bx+14D4h], dx - mov [bx+14D2h], ax - or ax, dx - jnz short loc_DEF4 - call file_close - -loc_DEEF: - mov ax, 1 - jmp short loc_DF5C -; --------------------------------------------------------------------------- - -loc_DEF4: - inc word ptr [bp-0Ah] - -loc_DEF7: - les bx, [bp-8] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, [bp-0Ah] - jg short loc_DEAA - mov bx, di - shl bx, 2 - pushd dword ptr [bx+1492h] - push word ptr [bp-2] - call file_read - mov word ptr [bp-0Ah], 0 - jmp short loc_DF3B -; --------------------------------------------------------------------------- - -loc_DF1E: - mov bx, di - shl bx, 6 - mov ax, [bp-0Ah] - shl ax, 2 - add bx, ax - pushd dword ptr [bx+14D2h] - push word ptr [bp-4] - call file_read - inc word ptr [bp-0Ah] - -loc_DF3B: - les bx, [bp-8] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, [bp-0Ah] - jg short loc_DF1E - push word ptr [bp-6] - push bx - call @$bdla$qnv - add sp, 4 - call file_close - xor ax, ax - -loc_DF5C: - pop di - pop si - leave - retf -; --------------------------------------------------------------------------- - enter 4, 0 - push si - push di - mov si, [bp+6] - pushd dword ptr [bp+8] - call file_ropen - or ax, ax - jz loc_DFFF - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov [bp-2], dx - mov [bp-4], ax - push dx - push ax - push 40h - call file_read - push 4 - push ds - push offset aHgrx ; "HGRX" - pushd dword ptr [bp-4] - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_DFAC - call file_close - jmp short loc_DFFF -; --------------------------------------------------------------------------- - -loc_DFAC: - les bx, [bp-4] - cmp byte ptr es:[bx+4], 1 - jnb short loc_DFBD - call file_close - jmp short loc_DFFF -; --------------------------------------------------------------------------- - -loc_DFBD: - les bx, [bp-4] - mov al, es:[bx+4] - mov [si+18D2h], al - mov di, es:[bx+8] - mov bx, si - shl bx, 2 - mov ax, [bx+1492h] - or ax, [bx+1494h] - jz short loc_DFE2 - push si - nopcall sub_E02B - pop cx - -loc_DFE2: - push di - call @$bnwa$qui - pop cx - mov bx, si - shl bx, 2 - mov [bx+1494h], dx - mov [bx+1492h], ax - or ax, dx - jnz short loc_E004 - call file_close - -loc_DFFF: - mov ax, 1 - jmp short loc_E027 -; --------------------------------------------------------------------------- - -loc_E004: - mov bx, si - shl bx, 2 - pushd dword ptr [bx+1492h] - push di - call file_read - pushd dword ptr [bp-4] - call @$bdla$qnv - add sp, 4 - call file_close - xor ax, ax - -loc_E027: - pop di - pop si - leave - retf - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E02B proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - mov si, [bp+arg_0] - mov bx, si - shl bx, 2 - mov ax, [bx+1492h] - or ax, [bx+1494h] - jz short loc_E065 - mov bx, si - shl bx, 2 - pushd dword ptr [bx+1492h] ; font - call @$bdla$qnv - add sp, 4 - mov bx, si - shl bx, 2 - mov word ptr [bx+1494h], 0 - mov word ptr [bx+1492h], 0 - -loc_E065: - xor di, di - jmp short loc_E0B1 -; --------------------------------------------------------------------------- - -loc_E069: - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov ax, [bx+14D2h] - or ax, [bx+14D4h] - jz short loc_E0B0 - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - pushd dword ptr [bx+14D2h] ; font - call @$bdla$qnv - add sp, 4 - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov word ptr [bx+14D4h], 0 - mov word ptr [bx+14D2h], 0 - -loc_E0B0: - inc di - -loc_E0B1: - cmp di, 10h - jl short loc_E069 - pop di - pop si - pop bp - retf -sub_E02B endp - -; --------------------------------------------------------------------------- - enter 0Eh, 0 - push si - push di - pushd dword ptr [bp+8] - call file_ropen - or ax, ax - jz loc_E213 - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov [bp-6], dx - mov [bp-8], ax - push dx - push ax - push 60h - call file_read - push 4 - push ds - push offset aHgrz ; "HGRZ" - pushd dword ptr [bp-8] - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_E104 - call file_close - jmp loc_E213 -; --------------------------------------------------------------------------- - -loc_E104: - les bx, [bp-8] - mov al, es:[bx+4] - mov [bp-9], al - mov ah, 0 - cmp ax, [bp+0Ch] - jle loc_E265 - mov ax, [bp+0Ch] - shl ax, 2 - add ax, 8 - mov di, ax - add bx, di - mov eax, es:[bx] - mov [bp-0Eh], eax - push eax - push 0 - call file_seek - pushd dword ptr [bp-8] - push 40h - call file_read - push 4 - push ds - push offset aHgrx ; "HGRX" - pushd dword ptr [bp-8] - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_E15E - call file_close - jmp loc_E213 -; --------------------------------------------------------------------------- - -loc_E15E: - les bx, [bp-8] - cmp byte ptr es:[bx+4], 1 - jnb short loc_E170 - call file_close - jmp loc_E213 -; --------------------------------------------------------------------------- - -loc_E170: - les bx, [bp-8] - mov al, es:[bx+4] - mov bx, [bp+6] - mov [bx+18D2h], al - mov bx, [bp-8] - mov ax, es:[bx+8] - mov [bp-2], ax - mov ax, es:[bx+0Ah] - mov [bp-4], ax - mov bx, [bp+6] - shl bx, 2 - mov ax, [bx+1492h] - or ax, [bx+1494h] - jz short loc_E1A7 - push word ptr [bp+6] - call sub_E02B - pop cx - -loc_E1A7: - push word ptr [bp-2] - call @$bnwa$qui - pop cx - mov bx, [bp+6] - shl bx, 2 - mov [bx+1494h], dx - mov [bx+1492h], ax - or ax, dx - jnz short loc_E1C9 - call file_close - jmp short loc_E213 -; --------------------------------------------------------------------------- - -loc_E1C9: - xor di, di - jmp short loc_E219 -; --------------------------------------------------------------------------- - -loc_E1CD: - mov bx, [bp+6] - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov ax, [bx+14D2h] - or ax, [bx+14D4h] - jz short loc_E1EC - push word ptr [bp+6] - call sub_E02B - pop cx - -loc_E1EC: - push word ptr [bp-4] - call @$bnwa$qui - pop cx - mov bx, [bp+6] - shl bx, 6 - mov si, di - shl si, 2 - add bx, si - mov [bx+14D4h], dx - mov [bx+14D2h], ax - or ax, dx - jnz short loc_E218 - call file_close - -loc_E213: - mov ax, 1 - jmp short loc_E278 -; --------------------------------------------------------------------------- - -loc_E218: - inc di - -loc_E219: - les bx, [bp-8] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, di - jg short loc_E1CD - mov bx, [bp+6] - shl bx, 2 - pushd dword ptr [bx+1492h] - push word ptr [bp-2] - call file_read - xor di, di - jmp short loc_E258 -; --------------------------------------------------------------------------- - -loc_E23D: - mov bx, [bp+6] - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - pushd dword ptr [bx+14D2h] - push word ptr [bp-4] - call file_read - inc di - -loc_E258: - les bx, [bp-8] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, di - jg short loc_E23D - -loc_E265: - pushd dword ptr [bp-8] - call @$bdla$qnv - add sp, 4 - call file_close - xor ax, ax - -loc_E278: - pop di - pop si - leave - retf op_09_TEXT ends ; =========================================================================== @@ -4313,10 +3539,7 @@ word_129BA dw 1 db 0 db 0 byte_129C7 db 0 -byte_129C8 db 0 -byte_129C9 db 0 -aHgrx db 'HGRX',0 -aHgrz db 'HGRZ',0 +include th01/formats/grz[data].asm include libs/master.lib/version[data].asm include libs/master.lib/grp[data].asm include libs/master.lib/pal[data].asm @@ -4517,282 +3740,7 @@ palette_136D2 palette_t dd ? dd ? dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? +include th01/formats/grz[bss].asm ; void (*font)(void) font dd ? include libs/master.lib/pal[bss].asm diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 94f958c7..cb13900a 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -6521,849 +6521,9 @@ arg_0 = dword ptr 6 retf sub_10C71 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10C9B proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 - - push bp - mov bp, sp - push si - mov si, [bp+arg_0] - mov al, [si+4478h] - mov ah, 0 - cmp ax, [bp+arg_2] - jle short loc_10CBF - mov al, byte ptr [bp+arg_2] - mov byte_350DE, al - push si - nopcall sub_10CDD - pop cx - mov byte_350DE, 0 - -loc_10CBF: - pop si - pop bp - retf -sub_10C9B endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10CC2 proc far - -arg_0 = word ptr 6 -arg_2 = byte ptr 8 - - push bp - mov bp, sp - mov al, [bp+arg_2] - inc al - mov byte_350DF, al - push [bp+arg_0] - nopcall sub_10CDD - pop cx - mov byte_350DF, 0 - pop bp - retf -sub_10CC2 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10CDD proc far - -var_2E = word ptr -2Eh -var_2C = word ptr -2Ch -var_29 = byte ptr -29h -var_28 = word ptr -28h -var_25 = byte ptr -25h -var_24 = word ptr -24h -var_21 = byte ptr -21h -var_20 = word ptr -20h -var_1D = byte ptr -1Dh -var_1C = word ptr -1Ch -var_1A = word ptr -1Ah -var_17 = byte ptr -17h -var_16 = word ptr -16h -var_13 = byte ptr -13h -var_12 = word ptr -12h -var_F = byte ptr -0Fh -var_E = word ptr -0Eh -var_B = byte ptr -0Bh -var_A = dword ptr -0Ah -var_6 = dword ptr -6 -var_2 = byte ptr -2 -var_1 = byte ptr -1 -arg_0 = word ptr 6 - - enter 2Eh, 0 - push si - push di - mov di, [bp+arg_0] - mov bx, di - shl bx, 2 - mov ax, [bx+403Ah] - mov dx, [bx+4038h] - mov word ptr [bp+var_6+2], ax - mov word ptr [bp+var_6], dx - mov bx, di - shl bx, 6 - mov al, byte_350DE - cbw - shl ax, 2 - add bx, ax - mov ax, [bx+407Ah] - mov dx, [bx+4078h] - mov word ptr [bp+var_A+2], ax - mov word ptr [bp+var_A], dx - cmp byte_350DF, 0 - jz short loc_10D28 - mov al, byte_350DF - cbw - dec ax - call _grcg_setcolor_rmw stdcall, ax - pop cx - -loc_10D28: - xor si, si - jmp loc_10E9E -; --------------------------------------------------------------------------- - -loc_10D2D: - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_1], al - inc word ptr [bp+var_6] - cmp [bp+var_1], 1 - jnz loc_10E09 - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_2], al - inc word ptr [bp+var_6] - cmp [bp+var_2], 0 - jz loc_10E09 - les bx, [bp+var_6] - mov al, es:[bx] - mov [bp+var_1], al - inc word ptr [bp+var_6] - jmp loc_10DFD -; --------------------------------------------------------------------------- - -loc_10D64: - cmp [bp+var_1], 0 - jnz loc_10DFC - cmp byte_350DF, 0 - jnz short loc_10DEA - les bx, [bp+var_A] - mov al, es:[bx] - mov [bp+var_B], al - inc word ptr [bp+var_A] - mov [bp+var_E], si - mov ax, 0A800h - mov bx, [bp+var_E] - mov dl, [bp+var_B] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_F], al - inc word ptr [bp+var_A] - mov [bp+var_12], si - mov ax, 0B000h - mov bx, [bp+var_12] - mov dl, [bp+var_F] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_13], al - inc word ptr [bp+var_A] - mov [bp+var_16], si - mov ax, 0B800h - mov bx, [bp+var_16] - mov dl, [bp+var_13] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_17], al - inc word ptr [bp+var_A] - mov [bp+var_1A], si - inc si - mov ax, 0E000h - mov bx, [bp+var_1A] - mov dl, [bp+var_17] - mov es, ax - assume es:nothing - mov es:[bx], dl - jmp short loc_10DFD -; --------------------------------------------------------------------------- - -loc_10DEA: - mov [bp+var_1C], si - inc si - mov ax, 0A800h - mov bx, [bp+var_1C] - mov es, ax - assume es:nothing - mov byte ptr es:[bx], 0FFh - jmp short loc_10DFD -; --------------------------------------------------------------------------- - -loc_10DFC: - inc si - -loc_10DFD: - mov al, [bp+var_2] - dec [bp+var_2] - or al, al - jnz loc_10D64 - -loc_10E09: - cmp [bp+var_1], 0 - jnz loc_10E9D - cmp byte_350DF, 0 - jnz short loc_10E8E - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_1D], al - inc word ptr [bp+var_A] - mov [bp+var_20], si - mov ax, 0A800h - mov bx, [bp+var_20] - mov dl, [bp+var_1D] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_21], al - inc word ptr [bp+var_A] - mov [bp+var_24], si - mov ax, 0B000h - mov bx, [bp+var_24] - mov dl, [bp+var_21] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_25], al - inc word ptr [bp+var_A] - mov [bp+var_28], si - mov ax, 0B800h - mov bx, [bp+var_28] - mov dl, [bp+var_25] - mov es, ax - assume es:nothing - mov es:[bx], dl - les bx, [bp+var_A] - assume es:nothing - mov al, es:[bx] - mov [bp+var_29], al - inc word ptr [bp+var_A] - mov [bp+var_2C], si - mov ax, 0E000h - mov bx, [bp+var_2C] - mov dl, [bp+var_29] - mov es, ax - assume es:nothing - mov es:[bx], dl - jmp short loc_10E9D -; --------------------------------------------------------------------------- - -loc_10E8E: - mov [bp+var_2E], si - mov ax, 0A800h - mov bx, [bp+var_2E] - mov es, ax - assume es:nothing - mov byte ptr es:[bx], 0FFh - -loc_10E9D: - inc si - -loc_10E9E: - cmp si, 7D00h - jb loc_10D2D - cmp byte_350DF, 0 - jz short loc_10EB2 - call _grcg_off_func - -loc_10EB2: - pop di - pop si - leave - retf -sub_10CDD endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10EB6 proc far - -var_A = word ptr -0Ah -_font = dword ptr -8 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - enter 0Ah, 0 - push si - push di - mov di, [bp+arg_0] - pushd [bp+arg_2] - call file_ropen - or ax, ax - jz loc_10FB1 - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov word ptr [bp+_font+2], dx - mov word ptr [bp+_font], ax - push dx - push ax - push 40h - call file_read - push 4 ; n - push ds - push offset aHgrx ; "HGRX" - pushd [bp+_font] ; s1 - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_10F03 - call file_close - jmp loc_10FB1 -; --------------------------------------------------------------------------- - -loc_10F03: - les bx, [bp+_font] - assume es:nothing - cmp byte ptr es:[bx+4], 1 - jnb short loc_10F15 - call file_close - jmp loc_10FB1 -; --------------------------------------------------------------------------- - -loc_10F15: - les bx, [bp+_font] - mov al, es:[bx+4] - mov [di+4478h], al - mov ax, es:[bx+8] - mov [bp+var_2], ax - mov ax, es:[bx+0Ah] - mov [bp+var_4], ax - mov bx, di - shl bx, 2 - mov ax, [bx+4038h] - or ax, [bx+403Ah] - jz short loc_10F44 - push di - nopcall sub_110ED - pop cx - -loc_10F44: - push [bp+var_2] - call @$bnwa$qui - pop cx - mov bx, di - shl bx, 2 - mov [bx+403Ah], dx - mov [bx+4038h], ax - or ax, dx - jnz short loc_10F65 - call file_close - jmp short loc_10FB1 -; --------------------------------------------------------------------------- - -loc_10F65: - mov [bp+var_A], 0 - jmp short loc_10FB9 -; --------------------------------------------------------------------------- - -loc_10F6C: - mov bx, di - shl bx, 6 - mov ax, [bp+var_A] - shl ax, 2 - add bx, ax - mov ax, [bx+4078h] - or ax, [bx+407Ah] - jz short loc_10F8A - push di - nopcall sub_110ED - pop cx - -loc_10F8A: - push [bp+var_4] - call @$bnwa$qui - pop cx - mov bx, di - shl bx, 6 - mov si, [bp+var_A] - shl si, 2 - add bx, si - mov [bx+407Ah], dx - mov [bx+4078h], ax - or ax, dx - jnz short loc_10FB6 - call file_close - -loc_10FB1: - mov ax, 1 - jmp short loc_1101E -; --------------------------------------------------------------------------- - -loc_10FB6: - inc [bp+var_A] - -loc_10FB9: - les bx, [bp+_font] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, [bp+var_A] - jg short loc_10F6C - mov bx, di - shl bx, 2 - pushd dword ptr [bx+4038h] - push [bp+var_2] - call file_read - mov [bp+var_A], 0 - jmp short loc_10FFD -; --------------------------------------------------------------------------- - -loc_10FE0: - mov bx, di - shl bx, 6 - mov ax, [bp+var_A] - shl ax, 2 - add bx, ax - pushd dword ptr [bx+4078h] - push [bp+var_4] - call file_read - inc [bp+var_A] - -loc_10FFD: - les bx, [bp+_font] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, [bp+var_A] - jg short loc_10FE0 - push word ptr [bp+_font+2] - push bx ; font - call @$bdla$qnv - add sp, 4 - call file_close - xor ax, ax - -loc_1101E: - pop di - pop si - leave - retf -sub_10EB6 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11022 proc far - -_font = dword ptr -4 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 - - enter 4, 0 - push si - push di - mov si, [bp+arg_0] - pushd [bp+arg_2] - call file_ropen - or ax, ax - jz loc_110C1 - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov word ptr [bp+_font+2], dx - mov word ptr [bp+_font], ax - push dx - push ax - push 40h - call file_read - push 4 ; n - push ds - push offset aHgrx ; "HGRX" - pushd [bp+_font] ; s1 - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_1106E - call file_close - jmp short loc_110C1 -; --------------------------------------------------------------------------- - -loc_1106E: - les bx, [bp+_font] - cmp byte ptr es:[bx+4], 1 - jnb short loc_1107F - call file_close - jmp short loc_110C1 -; --------------------------------------------------------------------------- - -loc_1107F: - les bx, [bp+_font] - mov al, es:[bx+4] - mov [si+4478h], al - mov di, es:[bx+8] - mov bx, si - shl bx, 2 - mov ax, [bx+4038h] - or ax, [bx+403Ah] - jz short loc_110A4 - push si - nopcall sub_110ED - pop cx - -loc_110A4: - push di - call @$bnwa$qui - pop cx - mov bx, si - shl bx, 2 - mov [bx+403Ah], dx - mov [bx+4038h], ax - or ax, dx - jnz short loc_110C6 - call file_close - -loc_110C1: - mov ax, 1 - jmp short loc_110E9 -; --------------------------------------------------------------------------- - -loc_110C6: - mov bx, si - shl bx, 2 - pushd dword ptr [bx+4038h] - push di - call file_read - pushd [bp+_font] ; font - call @$bdla$qnv - add sp, 4 - call file_close - xor ax, ax - -loc_110E9: - pop di - pop si - leave - retf -sub_11022 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_110ED proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - mov si, [bp+arg_0] - mov bx, si - shl bx, 2 - mov ax, [bx+4038h] - or ax, [bx+403Ah] - jz short loc_11127 - mov bx, si - shl bx, 2 - pushd dword ptr [bx+4038h] ; font - call @$bdla$qnv - add sp, 4 - mov bx, si - shl bx, 2 - mov word ptr [bx+403Ah], 0 - mov word ptr [bx+4038h], 0 - -loc_11127: - xor di, di - jmp short loc_11173 -; --------------------------------------------------------------------------- - -loc_1112B: - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov ax, [bx+4078h] - or ax, [bx+407Ah] - jz short loc_11172 - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - pushd dword ptr [bx+4078h] ; font - call @$bdla$qnv - add sp, 4 - mov bx, si - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov word ptr [bx+407Ah], 0 - mov word ptr [bx+4078h], 0 - -loc_11172: - inc di - -loc_11173: - cmp di, 10h - jl short loc_1112B - pop di - pop si - pop bp - retf -sub_110ED endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_1117C proc far - -var_E = dword ptr -0Eh -var_9 = byte ptr -9 -s1 = dword ptr -8 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 -arg_6 = word ptr 0Ch - - enter 0Eh, 0 - push si - push di - pushd [bp+arg_2] - call file_ropen - or ax, ax - jz loc_112D5 - push 64h ; 'd' - call @$bnwa$qui - pop cx - mov word ptr [bp+s1+2], dx - mov word ptr [bp+s1], ax - push dx - push ax - push 60h - call file_read - push 4 ; n - push ds - push offset aHgrz ; "HGRZ" - pushd [bp+s1] ; s1 - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_111C6 - call file_close - jmp loc_112D5 -; --------------------------------------------------------------------------- - -loc_111C6: - les bx, [bp+s1] - mov al, es:[bx+4] - mov [bp+var_9], al - mov ah, 0 - cmp ax, [bp+arg_6] - jle loc_11327 - mov ax, [bp+arg_6] - shl ax, 2 - add ax, 8 - mov di, ax - add bx, di - mov eax, es:[bx] - mov [bp+var_E], eax - push eax - push 0 - call file_seek - pushd [bp+s1] - push 40h - call file_read - push 4 ; n - push ds - push offset aHgrx ; "HGRX" - pushd [bp+s1] ; s1 - call _memcmp - add sp, 0Ah - or ax, ax - jz short loc_11220 - call file_close - jmp loc_112D5 -; --------------------------------------------------------------------------- - -loc_11220: - les bx, [bp+s1] - cmp byte ptr es:[bx+4], 1 - jnb short loc_11232 - call file_close - jmp loc_112D5 -; --------------------------------------------------------------------------- - -loc_11232: - les bx, [bp+s1] - mov al, es:[bx+4] - mov bx, [bp+arg_0] - mov [bx+4478h], al - mov bx, word ptr [bp+s1] - mov ax, es:[bx+8] - mov [bp+var_2], ax - mov ax, es:[bx+0Ah] - mov [bp+var_4], ax - mov bx, [bp+arg_0] - shl bx, 2 - mov ax, [bx+4038h] - or ax, [bx+403Ah] - jz short loc_11269 - push [bp+arg_0] - call sub_110ED - pop cx - -loc_11269: - push [bp+var_2] - call @$bnwa$qui - pop cx - mov bx, [bp+arg_0] - shl bx, 2 - mov [bx+403Ah], dx - mov [bx+4038h], ax - or ax, dx - jnz short loc_1128B - call file_close - jmp short loc_112D5 -; --------------------------------------------------------------------------- - -loc_1128B: - xor di, di - jmp short loc_112DB -; --------------------------------------------------------------------------- - -loc_1128F: - mov bx, [bp+arg_0] - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - mov ax, [bx+4078h] - or ax, [bx+407Ah] - jz short loc_112AE - push [bp+arg_0] - call sub_110ED - pop cx - -loc_112AE: - push [bp+var_4] - call @$bnwa$qui - pop cx - mov bx, [bp+arg_0] - shl bx, 6 - mov si, di - shl si, 2 - add bx, si - mov [bx+407Ah], dx - mov [bx+4078h], ax - or ax, dx - jnz short loc_112DA - call file_close - -loc_112D5: - mov ax, 1 - jmp short loc_1133A -; --------------------------------------------------------------------------- - -loc_112DA: - inc di - -loc_112DB: - les bx, [bp+s1] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, di - jg short loc_1128F - mov bx, [bp+arg_0] - shl bx, 2 - pushd dword ptr [bx+4038h] - push [bp+var_2] - call file_read - xor di, di - jmp short loc_1131A -; --------------------------------------------------------------------------- - -loc_112FF: - mov bx, [bp+arg_0] - shl bx, 6 - mov ax, di - shl ax, 2 - add bx, ax - pushd dword ptr [bx+4078h] - push [bp+var_4] - call file_read - inc di - -loc_1131A: - les bx, [bp+s1] - mov al, es:[bx+4] - mov ah, 0 - cmp ax, di - jg short loc_112FF - -loc_11327: - pushd [bp+s1] ; font - call @$bdla$qnv - -loc_11330: - add sp, 4 - -loc_11333: - call file_close - xor ax, ax - -loc_1133A: - pop di - pop si - leave - retf -sub_1117C endp - + extern _grx_put:proc + extern _grx_free:proc + extern _grz_load_single:proc main_08_TEXT ends ; =========================================================================== @@ -25409,10 +24569,7 @@ word_350D0 dw 1 db 0 db 0 byte_350DD db 0 -byte_350DE db 0 -byte_350DF db 0 -aHgrx db 'HGRX',0 -aHgrz db 'HGRZ',0 +include th01/formats/grz[data].asm include libs/master.lib/version[data].asm include libs/master.lib/tx[data].asm include libs/master.lib/grp[data].asm @@ -28636,282 +27793,7 @@ palette_38988 palette_t dd ? dd ? dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? - dd ? +include th01/formats/grz[bss].asm ; void (*off_38E28)(void) off_38E28 dd ? include libs/master.lib/pal[bss].asm diff --git a/th01_reiiden_2.inc b/th01_reiiden_2.inc index d30bc3f4..a833a041 100644 --- a/th01_reiiden_2.inc +++ b/th01_reiiden_2.inc @@ -31549,42 +31549,14 @@ loc_2D06B: loc_2D079: push 0 call sub_11738 - push 0 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - push 1 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 1 - call sub_1117C - push 2 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 2 - call sub_1117C - push 3 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 3 - call sub_1117C - push 4 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 4 - call sub_1117C - push 5 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 5 - call sub_1117C + call _grz_load_single stdcall, 0, offset aBoss8_grz, ds, 0 ; "boss8.grz" + call _grz_load_single stdcall, 1, offset aBoss8_grz, ds, 1 ; "boss8.grz" + call _grz_load_single stdcall, 2, offset aBoss8_grz, ds, 2 ; "boss8.grz" + call _grz_load_single stdcall, 3, offset aBoss8_grz, ds, 3 ; "boss8.grz" + call _grz_load_single stdcall, 4, offset aBoss8_grz, ds, 4 ; "boss8.grz" + call _grz_load_single stdcall, 5, offset aBoss8_grz, ds, 5 ; "boss8.grz" add sp, 32h - push 6 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 6 - call sub_1117C + call _grz_load_single stdcall, 6, offset aBoss8_grz, ds, 6 ; "boss8.grz" push 28h ; '(' call _frame_delay add sp, 0Ah @@ -31777,8 +31749,7 @@ sub_2D241 proc far ; --------------------------------------------------------------------------- loc_2D261: - push si - call sub_110ED + call _grx_free stdcall, si pop cx inc si @@ -31974,20 +31945,16 @@ sub_2D343 endp sub_2D412 proc far -arg_0 = word ptr 6 +@@slot = word ptr 6 push bp mov bp, sp push si - mov si, [bp+arg_0] - push 1 - call _graph_accesspage_func - push si - call sub_10CDD - push 0 - call _graph_accesspage_func - push si - call sub_10CDD + mov si, [bp+@@slot] + call _graph_accesspage_func stdcall, 1 + call _grx_put stdcall, si + call _graph_accesspage_func stdcall, 0 + call _grx_put stdcall, si add sp, 8 pop si pop bp @@ -33986,8 +33953,7 @@ sub_2E705 proc far jl loc_2E7C2 cmp word_3A6CA, 32h ; '2' jnz short loc_2E728 - push 0 - call sub_2D412 + call sub_2D412 stdcall, 0 push 8 call _mdrv2_se_play add sp, 4 @@ -33997,8 +33963,7 @@ loc_2E728: jl loc_2E7C2 cmp word_3A6CA, 3Ch ; '<' jnz short loc_2E73F - push 1 - call sub_2D412 + call sub_2D412 stdcall, 1 pop cx loc_2E73F: @@ -34006,8 +33971,7 @@ loc_2E73F: jl short loc_2E7C2 cmp word_3A6CA, 64h ; 'd' jnz short loc_2E754 - push 2 - call sub_2D412 + call sub_2D412 stdcall, 2 pop cx loc_2E754: @@ -34015,8 +33979,7 @@ loc_2E754: jl short loc_2E7C2 cmp word_3A6CA, 78h ; 'x' jnz short loc_2E769 - push 3 - call sub_2D412 + call sub_2D412 stdcall, 3 pop cx loc_2E769: @@ -34024,8 +33987,7 @@ loc_2E769: jl short loc_2E7C2 cmp word_3A6CA, 8Ch jnz short loc_2E780 - push 4 - call sub_2D412 + call sub_2D412 stdcall, 4 pop cx loc_2E780: @@ -34033,8 +33995,7 @@ loc_2E780: jl short loc_2E7C2 cmp word_3A6CA, 0A0h ; '?' jnz short loc_2E797 - push 5 - call sub_2D412 + call sub_2D412 stdcall, 5 pop cx loc_2E797: @@ -34042,8 +34003,7 @@ loc_2E797: jl short loc_2E7C2 cmp word_3A6CA, 0AAh ; '?' jnz short loc_2E7AE - push 6 - call sub_2D412 + call sub_2D412 stdcall, 6 pop cx loc_2E7AE: @@ -35672,129 +35632,74 @@ loc_2F766: call _z_graph_clear call _mdrv2_bgm_stop call _z_palette_set_show c, large (0 shl 16) or 0, large (0 shl 16) or 0 - push 7 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 - push 0 - call sub_10CDD + call _grz_load_single c, 0, offset aBoss8_grz, ds, 7 ; "boss8.grz" + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 8 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 8 ; "boss8.grz" call _z_palette_set_show c, large (0Fh shl 16) or 00h, large (0Fh shl 16) or 0Fh - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 9 - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 9 ; "boss8.grz" call _z_palette_set_show c, large (0 shl 16) or 0, large (0 shl 16) or 0 - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Ah - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 10 ; "boss8.grz" call _z_palette_set_show c, large (0Fh shl 16) or 00h, large (0Fh shl 16) or 0Fh - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Bh - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 11 ; "boss8.grz" call _z_palette_set_show c, large (0 shl 16) or 0, large (0 shl 16) or 0 - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Ch - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 12 ; "boss8.grz" call _z_palette_set_show c, large (0Fh shl 16) or 00h, large (0Fh shl 16) or 0Fh - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Dh - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 13 ; "boss8.grz" call _z_palette_set_show c, large (0 shl 16) or 0, large (0 shl 16) or 0 - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Eh - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 14 ; "boss8.grz" call _z_palette_set_show c, large (0Fh shl 16) or 00h, large (0Fh shl 16) or 0Fh - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx push 0Ah call _frame_delay pop cx call _z_graph_clear - push 0Fh - push ds - push offset aBoss8_grz ; "boss8.grz" - push 0 - call sub_1117C - add sp, 8 + call _grz_load_single c, 0, offset aBoss8_grz, ds, 15 ; "boss8.grz" call _z_palette_set_show c, large (0 shl 16) or 0, large (0 shl 16) or 0 - push 0 - call sub_10CDD + call _grx_put stdcall, 0 pop cx - push 0 - call sub_110ED + call _grx_free stdcall, 0 pop cx push 0Ah call _frame_delay