mirror of
https://github.com/StanHash/fomt.git
synced 2024-10-07 02:23:20 +00:00
func_080E0EB4 is instanciation of std::lower_bound
This commit is contained in:
parent
bc99598c0a
commit
7e841e16a0
4
Makefile
4
Makefile
@ -106,7 +106,7 @@ $(BUILD_DIR)/%.d: %.c
|
||||
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.d
|
||||
@echo "CC $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(CC1) $(CFLAGS) -o $(BUILD_DIR)/$*.s
|
||||
@echo ".text\n\t.align\t2, 0\n" >> $(BUILD_DIR)/$*.s
|
||||
@tools/scripts/align_sections.sh $(BUILD_DIR)/$*.s
|
||||
@$(AS) $(ASFLAGS) $(BUILD_DIR)/$*.s -o $@
|
||||
|
||||
# C++ dependency file
|
||||
@ -117,7 +117,7 @@ $(BUILD_DIR)/%.d: %.cc
|
||||
$(BUILD_DIR)/%.o: %.cc $(BUILD_DIR)/%.d
|
||||
@echo "CP $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(CC1PLUS) $(CXXFLAGS) -o $(BUILD_DIR)/$*.s
|
||||
@echo ".text\n\t.align\t2, 0\n" >> $(BUILD_DIR)/$*.s
|
||||
@tools/scripts/align_sections.sh $(BUILD_DIR)/$*.s
|
||||
@$(AS) $(ASFLAGS) $(BUILD_DIR)/$*.s -o $@
|
||||
|
||||
# ASM dependency file (dummy, generated with the object)
|
||||
|
@ -26049,43 +26049,7 @@ _080E0EAC:
|
||||
pop {r1}
|
||||
bx r1
|
||||
|
||||
thumb_func_start func_080E0EB4
|
||||
func_080E0EB4: @ 0x080E0EB4
|
||||
push {r4, r5, r6, lr}
|
||||
adds r5, r0, #0
|
||||
subs r1, r1, r5
|
||||
asrs r1, r1, #3
|
||||
cmp r1, #0
|
||||
ble _080E0EE6
|
||||
ldr r6, [r2]
|
||||
_080E0EC2:
|
||||
asrs r3, r1, #1
|
||||
lsls r0, r3, #3
|
||||
adds r2, r5, r0
|
||||
movs r4, #0
|
||||
ldr r0, [r2]
|
||||
cmp r0, r6
|
||||
bge _080E0ED2
|
||||
movs r4, #1
|
||||
_080E0ED2:
|
||||
cmp r4, #0
|
||||
beq _080E0EE0
|
||||
adds r5, r2, #0
|
||||
adds r5, #8
|
||||
subs r0, r1, r3
|
||||
subs r1, r0, #1
|
||||
b _080E0EE2
|
||||
_080E0EE0:
|
||||
adds r1, r3, #0
|
||||
_080E0EE2:
|
||||
cmp r1, #0
|
||||
bgt _080E0EC2
|
||||
_080E0EE6:
|
||||
adds r0, r5, #0
|
||||
pop {r4, r5, r6}
|
||||
pop {r1}
|
||||
bx r1
|
||||
.align 2, 0
|
||||
.section ".text.code_080E0EF0"
|
||||
|
||||
thumb_func_start func_080E0EF0
|
||||
func_080E0EF0: @ 0x080E0EF0
|
||||
|
@ -466,4 +466,4 @@ gUnk_080F8678:
|
||||
|
||||
.global gUnk_080F89D4 @ script table
|
||||
gUnk_080F89D4:
|
||||
.incbin "baserom.gba", 0xF89D4, 0x14D0
|
||||
.incbin "baserom.gba", 0xF89D4, 0x14C4
|
||||
|
2
fomt.lds
2
fomt.lds
@ -136,6 +136,8 @@ SECTIONS
|
||||
*(.gnu.linkonce.t.__as__3CowRC3Cow);
|
||||
*(.gnu.linkonce.t.__as__9LivestockRC9Livestock);
|
||||
asm/code_linkonce.o(.text.code_080D7CFC);
|
||||
*(.gnu.linkonce.t.__lower_bound__H4ZPC12JumpTableEntZiZ28ScriptJumpTableSearchCompareZl_X01T0RCX11X21PX31_X01);
|
||||
asm/code_linkonce.o(.text.code_080E0EF0);
|
||||
|
||||
*(.gnu.linkonce.d.__vt_6AScene);
|
||||
*(.gnu.linkonce.d.__vt_13AUnk_0800080C);
|
||||
|
@ -14,11 +14,6 @@ struct JumpTableEnt
|
||||
{
|
||||
int value;
|
||||
u32 target;
|
||||
|
||||
bool operator < (int const & other) const
|
||||
{
|
||||
return value < other;
|
||||
}
|
||||
};
|
||||
|
||||
struct ScriptStack
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "script_engine.hh"
|
||||
|
||||
// TODO: MOVE OUT
|
||||
// NOTE: this is something very similar to std::lower_bound, but with an extra arg (fsr)
|
||||
extern "C" JumpTableEnt const * func_080E0EB4(JumpTableEnt const * beg, JumpTableEnt const * end, int const & value, int *, int);
|
||||
#include <algorithm>
|
||||
|
||||
AScriptEngine::AScriptEngine()
|
||||
: unk_00(0)
|
||||
@ -202,6 +200,14 @@ void AScriptEngine::method_0803F0DC() const
|
||||
{
|
||||
}
|
||||
|
||||
struct ScriptJumpTableSearchCompare
|
||||
{
|
||||
bool operator() (JumpTableEnt const & left, int right)
|
||||
{
|
||||
return left.value < right;
|
||||
}
|
||||
};
|
||||
|
||||
int AScriptEngine::NextInstruction()
|
||||
{
|
||||
switch (Opcode(pc))
|
||||
@ -577,7 +583,7 @@ int AScriptEngine::NextInstruction()
|
||||
int value = stack.Top();
|
||||
stack.Pop();
|
||||
|
||||
JumpTableEnt const * ent = func_080E0EB4(beg, end, value, 0, 0);
|
||||
JumpTableEnt const * ent = std::lower_bound(beg, end, value, ScriptJumpTableSearchCompare());
|
||||
|
||||
if (ent != end && ent->value == value)
|
||||
{
|
||||
@ -605,7 +611,8 @@ int AScriptEngine::NextInstruction()
|
||||
|
||||
char const * AScriptEngine::GetString(u32 id) const
|
||||
{
|
||||
if ((u32)id <= (u32)string_count)
|
||||
// BUG: this should be strict compare
|
||||
if (id <= string_count)
|
||||
return string_pool + string_offset_table[id];
|
||||
|
||||
return "Error";
|
||||
|
@ -1723,8 +1723,7 @@ template <class _ForwardIter, class _Tp, class _Distance>
|
||||
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val, _Distance*)
|
||||
{
|
||||
_Distance __len = 0;
|
||||
distance(__first, __last, __len);
|
||||
_Distance __len = distance(__first, __last);
|
||||
_Distance __half;
|
||||
_ForwardIter __middle;
|
||||
|
||||
@ -1754,8 +1753,7 @@ template <class _ForwardIter, class _Tp, class _Compare, class _Distance>
|
||||
_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last,
|
||||
const _Tp& __val, _Compare __comp, _Distance*)
|
||||
{
|
||||
_Distance __len = 0;
|
||||
distance(__first, __last, __len);
|
||||
_Distance __len = distance(__first, __last);
|
||||
_Distance __half;
|
||||
_ForwardIter __middle;
|
||||
|
||||
|
10
tools/scripts/align_sections.sh
Executable file
10
tools/scripts/align_sections.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
for sec in $(sed -n -e 's/^\t\.section \([a-zA-Z0-9_\.]\+\),"ax",%progbits$/\1/p' $1)
|
||||
do
|
||||
echo " .section \"$sec\"" >> $1
|
||||
echo " .align 2, 0" >> $1
|
||||
done
|
||||
|
||||
echo " .text" >> $1
|
||||
echo " .align 2, 0" >> $1
|
Loading…
Reference in New Issue
Block a user