[Separate translation units] [th01] ptn_copy_8_0_to_1()

So, we have a problem. The ridiculously optimized graph_putsa_fx() used
in TH04 and TH05 swaps out the target of two CALL instructions at
run-time… because there *really* wasn't any free register left for an
indirect CALL, eh? Therefore, the necessary relative addresses have to
be calculated at assembly time, by subtracting the target function
label from the call site label.
Unfortunately, the resulting values are stored in the .DATA segment,
which we can't move out right now. Declaring the labels as EXTERN
wouldn't work either, since the linker can't do fancy arithmetic and is
limited to simply replacing address placeholders with one single
address. This is explained pretty well at:

	http://computer-programming-forum.com/46-asm/48f3d4a463bb38d1.htm

Which means we're stuck, and can't separate out this function for the
foreseeable future.

So, time to approach the SHARED segment from the top instead, to at
least get everything around graph_putsa_fx() done now. 🤷
vram_planes_set() is the first common function there. But since it was
introduced in TH01, we've got some maintenance to do for that game
first…

Part of P0138, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2021-04-11 14:24:21 +02:00
parent 9d2cce16a2
commit 7b3b6fd4e7
8 changed files with 27 additions and 10 deletions

View File

@ -55,12 +55,12 @@ bin\frmdely2.obj: th02\frmdely2.c
{th01}.cpp{bin\th01}.obj:
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=1 -n$(@D) -c $**
bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp bin\th01\frmdely.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj th01\op_07.cpp bin\th01\grppffx.obj bin\th01\ptn.obj th01\op_09.cpp bin\th01\grz.obj bin\th01\resstuff.obj bin\th01\mdrv2.obj th01\op_12.cpp
bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp bin\th01\frmdely.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj th01\op_07.cpp bin\th01\grppffx.obj bin\th01\ptn.obj th01\op_09.cpp bin\th01\grz.obj bin\th01\resstuff.obj bin\th01\mdrv2.obj th01\op_12.cpp
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=1 -DBINARY='O' -nbin\th01\ -eOP.EXE @&&|
$**
|
bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_01.cpp th01\main_01_.cpp bin\th01\frmdely.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_25.cpp th01\main_27.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp
bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_01.cpp th01\main_01_.cpp bin\th01\frmdely.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_25.cpp th01\main_27.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&|
$**
|

View File

@ -1,3 +1,10 @@
#pragma option -zCSHARED
extern "C" {
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "th01/hardware/graph.h"
#include "th01/formats/ptn.hpp"
void ptn_copy_8_0_to_1(screen_x_t left, vram_y_t top)
@ -11,3 +18,5 @@ void ptn_copy_8_0_to_1(screen_x_t left, vram_y_t top)
}
graph_accesspage_func(0);
}
}

View File

@ -1,4 +1,5 @@
extern "C" {
#include "th01/formats/ptn.hpp"
void ptn_snap_8(screen_x_t left, vram_y_t top, int ptn_id)
{

View File

@ -3,12 +3,15 @@
* Code segment #7 of TH01's REIIDEN.EXE
*/
#pragma option -zCSHARED
extern "C" {
#include "ReC98.h"
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "th01/hardware/graph.h"
#include "th01/formats/ptn_0to1.cpp"
#include "th01/hardware/vplanset.c"
#include "th01/hardware/egcrect.cpp"
#include "th01/formats/ptn_snap.cpp"

View File

@ -3,12 +3,15 @@
* Code segment #7 of TH01's OP.EXE
*/
#pragma option -zCSHARED
extern "C" {
#include "ReC98.h"
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "th01/hardware/graph.h"
#include "th01/formats/ptn_0to1.cpp"
#include "th01/hardware/vplanset.c"
#include "th01/hardware/egcrect.cpp"
#include "th01/formats/ptn_snap.cpp"

1
th01/ptn_0to1.cpp Normal file
View File

@ -0,0 +1 @@
#include "th01/formats/ptn_0to1.cpp"

View File

@ -1417,9 +1417,9 @@ graph_TEXT ends
; ===========================================================================
; Segment type: Pure code
op_07_TEXT segment byte public 'CODE' use16
SHARED segment byte public 'CODE' use16
extern _egc_copy_rect_1_to_0_16:proc
op_07_TEXT ends
SHARED ends
; ===========================================================================

View File

@ -4265,13 +4265,13 @@ graph_TEXT ends
; ===========================================================================
; Segment type: Pure code
main_07_TEXT segment byte public 'CODE' use16
SHARED segment byte public 'CODE' use16
extern _ptn_copy_8_0_to_1:proc
extern _vram_planes_set:proc
extern _egc_copy_rect_1_to_0_16:proc
extern _ptn_snap_8:proc
extern _ptn_snap_quarter_8:proc
main_07_TEXT ends
SHARED ends
; ===========================================================================