"Fixed" implementation of lwl/swl (fixes initial test games), implemented more controller functionality
This commit is contained in:
parent
aad1bac933
commit
6e45fac005
24
recomp.h
24
recomp.h
|
@ -65,9 +65,27 @@ static inline uint64_t load_doubleword(uint8_t* rdram, gpr reg, gpr offset) {
|
|||
load_doubleword(rdram, offset, reg)
|
||||
|
||||
// TODO proper lwl/lwr/swl/swr
|
||||
#define MEM_WL(offset, reg) \
|
||||
(*(int32_t*)(rdram + ((((reg) + (offset))) - 0xFFFFFFFF80000000)))
|
||||
//(*(int32_t*)(rdram + ((((reg) + (offset))) & 0x3FFFFFF)))
|
||||
static inline void do_swl(uint8_t* rdram, gpr offset, gpr reg, gpr val) {
|
||||
uint8_t byte0 = val >> 24;
|
||||
uint8_t byte1 = val >> 16;
|
||||
uint8_t byte2 = val >> 8;
|
||||
uint8_t byte3 = val >> 0;
|
||||
|
||||
MEM_B(offset + 0, reg) = byte0;
|
||||
MEM_B(offset + 1, reg) = byte1;
|
||||
MEM_B(offset + 2, reg) = byte2;
|
||||
MEM_B(offset + 3, reg) = byte3;
|
||||
}
|
||||
|
||||
static inline gpr do_lwl(uint8_t* rdram, gpr offset, gpr reg) {
|
||||
uint8_t byte0 = MEM_B(offset + 0, reg);
|
||||
uint8_t byte1 = MEM_B(offset + 1, reg);
|
||||
uint8_t byte2 = MEM_B(offset + 2, reg);
|
||||
uint8_t byte3 = MEM_B(offset + 3, reg);
|
||||
|
||||
// Cast to int32_t to sign extend first
|
||||
return (gpr)(int32_t)((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | (byte3 << 0));
|
||||
}
|
||||
|
||||
#define S32(val) \
|
||||
((int32_t)(val))
|
||||
|
|
|
@ -244,16 +244,20 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::F
|
|||
// LWR x + 2 -> 00000000 0189ABCD
|
||||
// LWR x + 3 -> FFFFFFFF 89ABCDEF
|
||||
case InstrId::cpu_lwl:
|
||||
print_line("{}{} = MEM_WL({:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
print_line("{}{} = do_lwl(rdram, {:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
//print_line("{}{} = MEM_WL({:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
break;
|
||||
case InstrId::cpu_lwr:
|
||||
print_line("//{}{} = MEM_WR({:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
//print_line("{}{} = do_lwr(rdram, {:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
//print_line("//{}{} = MEM_WR({:#X}, {}{})", ctx_gpr_prefix(rt), rt, (int16_t)imm, ctx_gpr_prefix(base), base);
|
||||
break;
|
||||
case InstrId::cpu_swl:
|
||||
print_line("MEM_WL({:#X}, {}{}) = {}{}", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
print_line("do_swl(rdram, {:#X}, {}{}, {}{})", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
//print_line("MEM_WL({:#X}, {}{}) = {}{}", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
break;
|
||||
case InstrId::cpu_swr:
|
||||
print_line("//MEM_WR({:#X}, {}{}) = {}{}", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
//print_line("do_swr(rdram, {:#X}, {}{}, {}{})", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
//print_line("//MEM_WR({:#X}, {}{}) = {}{}", (int16_t)imm, ctx_gpr_prefix(base), base, ctx_gpr_prefix(rt), rt);
|
||||
break;
|
||||
|
||||
// Branches
|
||||
|
|
|
@ -131,173 +131,9 @@ XCOPY "$(ProjectDir)Lib\SDL2-2.24.0\lib\$(Platform)\SDL2.dll" "$(TargetDir)" /S
|
|||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="funcs\addGfxToDrawLayer.c" />
|
||||
<ClCompile Include="funcs\addMtxToDrawLayer.c" />
|
||||
<ClCompile Include="funcs\allocChunks.c" />
|
||||
<ClCompile Include="funcs\allocEntities.c" />
|
||||
<ClCompile Include="funcs\allocGfx.c" />
|
||||
<ClCompile Include="funcs\allocRegion.c" />
|
||||
<ClCompile Include="funcs\applyGravityCallback.c" />
|
||||
<ClCompile Include="funcs\applyHoldableGravityCallback.c" />
|
||||
<ClCompile Include="funcs\applyHoldableVelocityCallback.c" />
|
||||
<ClCompile Include="funcs\applyVelocityCallback.c" />
|
||||
<ClCompile Include="funcs\approachFloatLinear.c" />
|
||||
<ClCompile Include="funcs\atan2s.c" />
|
||||
<ClCompile Include="funcs\atan2_lookup.c" />
|
||||
<ClCompile Include="funcs\audioInit.c" />
|
||||
<ClCompile Include="funcs\audioThreadFunc.c" />
|
||||
<ClCompile Include="funcs\beginInputPolling.c" />
|
||||
<ClCompile Include="funcs\bounceflowerResizeCallback.c" />
|
||||
<ClCompile Include="funcs\createEntities.c" />
|
||||
<ClCompile Include="funcs\createEntitiesCallback.c" />
|
||||
<ClCompile Include="funcs\createEntity.c" />
|
||||
<ClCompile Include="funcs\createPlayer.c" />
|
||||
<ClCompile Include="funcs\createPlayerCallback.c" />
|
||||
<ClCompile Include="funcs\deleteAllEntities.c" />
|
||||
<ClCompile Include="funcs\deleteEntity.c" />
|
||||
<ClCompile Include="funcs\deleteEntityIndex.c" />
|
||||
<ClCompile Include="funcs\drawAABB.c" />
|
||||
<ClCompile Include="funcs\drawAllEntities.c" />
|
||||
<ClCompile Include="funcs\drawAnimatedModels.c" />
|
||||
<ClCompile Include="funcs\drawColTris.c" />
|
||||
<ClCompile Include="funcs\drawGfx.c" />
|
||||
<ClCompile Include="funcs\drawLine.c" />
|
||||
<ClCompile Include="funcs\drawModel.c" />
|
||||
<ClCompile Include="funcs\drawModels.c" />
|
||||
<ClCompile Include="funcs\drawResizableAnimatedModels.c" />
|
||||
<ClCompile Include="funcs\drawResizableModels.c" />
|
||||
<ClCompile Include="funcs\endFrame.c" />
|
||||
<ClCompile Include="funcs\fastAtan2f.c" />
|
||||
<ClCompile Include="funcs\fastAtanf.c" />
|
||||
<ClCompile Include="funcs\fillAudioBuffer.c" />
|
||||
<ClCompile Include="funcs\findClosestCallback.c" />
|
||||
<ClCompile Include="funcs\findClosestEntity.c" />
|
||||
<ClCompile Include="funcs\findEntity.c" />
|
||||
<ClCompile Include="funcs\findEntityFromComponent.c" />
|
||||
<ClCompile Include="funcs\findNextGap.c" />
|
||||
<ClCompile Include="funcs\freeAlloc.c" />
|
||||
<ClCompile Include="funcs\freeIntroSegment.c" />
|
||||
<ClCompile Include="funcs\getArchetypeIndex.c" />
|
||||
<ClCompile Include="funcs\getEntityComponents.c" />
|
||||
<ClCompile Include="funcs\getSegment.c" />
|
||||
<ClCompile Include="funcs\gfxCbAfterBillboard.c" />
|
||||
<ClCompile Include="funcs\gfxCbBeforeBillboard.c" />
|
||||
<ClCompile Include="funcs\gfxSetEnvColor.c" />
|
||||
<ClCompile Include="funcs\guLookAt.c" />
|
||||
<ClCompile Include="funcs\guLookAtF.c" />
|
||||
<ClCompile Include="funcs\guLookAtReflect.c" />
|
||||
<ClCompile Include="funcs\guLookAtReflectF.c" />
|
||||
<ClCompile Include="funcs\guMtxF2L.c" />
|
||||
<ClCompile Include="funcs\guMtxIdent.c" />
|
||||
<ClCompile Include="funcs\guMtxIdentF.c" />
|
||||
<ClCompile Include="funcs\guOrtho.c" />
|
||||
<ClCompile Include="funcs\guOrthoF.c" />
|
||||
<ClCompile Include="funcs\guPerspective.c" />
|
||||
<ClCompile Include="funcs\guPerspectiveF.c" />
|
||||
<ClCompile Include="funcs\guScaleF.c" />
|
||||
<ClCompile Include="funcs\guTranslateF.c" />
|
||||
<ClCompile Include="funcs\handleFloorInAir.c" />
|
||||
<ClCompile Include="funcs\handleFloorOnGround.c" />
|
||||
<ClCompile Include="funcs\handleWalls.c" />
|
||||
<ClCompile Include="funcs\idle.c" />
|
||||
<ClCompile Include="funcs\indexOfSorted_size_t.c" />
|
||||
<ClCompile Include="funcs\init.c" />
|
||||
<ClCompile Include="funcs\initGfx.c" />
|
||||
<ClCompile Include="funcs\initInput.c" />
|
||||
<ClCompile Include="funcs\initMemAllocator.c" />
|
||||
<ClCompile Include="funcs\initScheduler.c" />
|
||||
<ClCompile Include="funcs\iterateOverEntities.c" />
|
||||
<ClCompile Include="funcs\iterateOverEntitiesAllComponents.c" />
|
||||
<ClCompile Include="funcs\levelCreateEntitiesCallback.c" />
|
||||
<ClCompile Include="funcs\lillypadResizeCallback.c" />
|
||||
<ClCompile Include="funcs\loadCreditsSegment.c" />
|
||||
<ClCompile Include="funcs\loadIntroSegment.c" />
|
||||
<_WildCardClCompile Include="funcs\*.c" />
|
||||
<ClCompile Include="@(_WildCardClCompile)" />
|
||||
<ClCompile Include="funcs\lookup.cpp" />
|
||||
<ClCompile Include="funcs\lowest_bit.c" />
|
||||
<ClCompile Include="funcs\mainThreadFunc.c" />
|
||||
<ClCompile Include="funcs\mtxfEulerXYZ.c" />
|
||||
<ClCompile Include="funcs\mtxfEulerXYZInverse.c" />
|
||||
<ClCompile Include="funcs\mtxfMul.c" />
|
||||
<ClCompile Include="funcs\mtxfRotateVec.c" />
|
||||
<ClCompile Include="funcs\mtxf_align_camera.c" />
|
||||
<ClCompile Include="funcs\multiarraylist_alloccount.c" />
|
||||
<ClCompile Include="funcs\multiarraylist_delete.c" />
|
||||
<ClCompile Include="funcs\multiarraylist_get_component_offset.c" />
|
||||
<ClCompile Include="funcs\multiarraylist_init.c" />
|
||||
<ClCompile Include="funcs\numberOfSetBits.c" />
|
||||
<ClCompile Include="funcs\osCreateScheduler.c" />
|
||||
<ClCompile Include="funcs\osScAddClient.c" />
|
||||
<ClCompile Include="funcs\osScGetCmdQ.c" />
|
||||
<ClCompile Include="funcs\osScRemoveClient.c" />
|
||||
<ClCompile Include="funcs\physicsTick.c" />
|
||||
<ClCompile Include="funcs\playerCallback.c" />
|
||||
<ClCompile Include="funcs\playSound.c" />
|
||||
<ClCompile Include="funcs\processAir.c" />
|
||||
<ClCompile Include="funcs\processBehaviorEntities.c" />
|
||||
<ClCompile Include="funcs\processGround.c" />
|
||||
<ClCompile Include="funcs\processLevelHeader.c" />
|
||||
<ClCompile Include="funcs\raycast.c" />
|
||||
<ClCompile Include="funcs\raycastIterator.c" />
|
||||
<ClCompile Include="funcs\raycastPositionIterator.c" />
|
||||
<ClCompile Include="funcs\raycastPositionRotationIterator.c" />
|
||||
<ClCompile Include="funcs\raycastPositionRotationVerticalIterator.c" />
|
||||
<ClCompile Include="funcs\raycastPositionVerticalIterator.c" />
|
||||
<ClCompile Include="funcs\raycastVertical.c" />
|
||||
<ClCompile Include="funcs\raycastVerticalIterator.c" />
|
||||
<ClCompile Include="funcs\rayVsAABB.c" />
|
||||
<ClCompile Include="funcs\rayVsBvh.c" />
|
||||
<ClCompile Include="funcs\rayVsTri.c" />
|
||||
<ClCompile Include="funcs\readInput.c" />
|
||||
<ClCompile Include="funcs\registerArchetype.c" />
|
||||
<ClCompile Include="funcs\removeDrawLayerSlot.c" />
|
||||
<ClCompile Include="funcs\resetGfxFrame.c" />
|
||||
<ClCompile Include="funcs\resizableCallback.c" />
|
||||
<ClCompile Include="funcs\resolveCollisionsCallback.c" />
|
||||
<ClCompile Include="funcs\resolveHoldableCollisionsCallback.c" />
|
||||
<ClCompile Include="funcs\rspUcodeLoadInit.c" />
|
||||
<ClCompile Include="funcs\scheduleGfxTask.c" />
|
||||
<ClCompile Include="funcs\scrollTextures.c" />
|
||||
<ClCompile Include="funcs\segmentedToVirtual.c" />
|
||||
<ClCompile Include="funcs\sendGfxTask.c" />
|
||||
<ClCompile Include="funcs\setAnim.c" />
|
||||
<ClCompile Include="funcs\setCollision.c" />
|
||||
<ClCompile Include="funcs\setLightDirection.c" />
|
||||
<ClCompile Include="funcs\setLogoCollision.c" />
|
||||
<ClCompile Include="funcs\setSegment.c" />
|
||||
<ClCompile Include="funcs\setupCameraMatrices.c" />
|
||||
<ClCompile Include="funcs\setupDrawLayers.c" />
|
||||
<ClCompile Include="funcs\sinsf.c" />
|
||||
<ClCompile Include="funcs\startCreditsLoad.c" />
|
||||
<ClCompile Include="funcs\startDMA.c" />
|
||||
<ClCompile Include="funcs\startFrame.c" />
|
||||
<ClCompile Include="funcs\testRayVsAABB.c" />
|
||||
<ClCompile Include="funcs\testVerticalRayVsAABB.c" />
|
||||
<ClCompile Include="funcs\tickResizables.c" />
|
||||
<ClCompile Include="funcs\treevineleafResizeCallback.c" />
|
||||
<ClCompile Include="funcs\updateAir.c" />
|
||||
<ClCompile Include="funcs\updateFirstFreeChunk.c" />
|
||||
<ClCompile Include="funcs\updateGround.c" />
|
||||
<ClCompile Include="funcs\verticalRayVsAABB.c" />
|
||||
<ClCompile Include="funcs\verticalRayVsBvh.c" />
|
||||
<ClCompile Include="funcs\verticalRayVsTri.c" />
|
||||
<ClCompile Include="funcs\waitForDMA.c" />
|
||||
<ClCompile Include="funcs\_memcpy.c" />
|
||||
<ClCompile Include="funcs\_memset.c" />
|
||||
<ClCompile Include="funcs\_sqrtf.c" />
|
||||
<ClCompile Include="funcs\_strchr.c" />
|
||||
<ClCompile Include="funcs\__cosf.c" />
|
||||
<ClCompile Include="funcs\__popcountsi2.c" />
|
||||
<ClCompile Include="funcs\__scAppendList.c" />
|
||||
<ClCompile Include="funcs\__scExec.c" />
|
||||
<ClCompile Include="funcs\__scHandleRDP.c" />
|
||||
<ClCompile Include="funcs\__scHandleRetrace.c" />
|
||||
<ClCompile Include="funcs\__scHandleRSP.c" />
|
||||
<ClCompile Include="funcs\__scMain.c" />
|
||||
<ClCompile Include="funcs\__scSchedule.c" />
|
||||
<ClCompile Include="funcs\__scTaskComplete.c" />
|
||||
<ClCompile Include="funcs\__scTaskReady.c" />
|
||||
<ClCompile Include="funcs\__scYield.c" />
|
||||
<ClCompile Include="funcs\__sinf.c" />
|
||||
<ClCompile Include="portultra\events.cpp" />
|
||||
<ClCompile Include="portultra\ultrainit.cpp" />
|
||||
<ClCompile Include="portultra\main.c" />
|
||||
|
@ -320,7 +156,6 @@ XCOPY "$(ProjectDir)Lib\SDL2-2.24.0\lib\$(Platform)\SDL2.dll" "$(TargetDir)" /S
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\recomp.h" />
|
||||
<ClInclude Include="funcs\funcs.h" />
|
||||
<ClInclude Include="portultra\multilibultra.hpp" />
|
||||
<ClInclude Include="portultra\platform_specific.h" />
|
||||
<ClInclude Include="RT64\rt64_layer.h" />
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -180,10 +180,14 @@ void RT64SendDL(uint8_t* rdram, const OSTask* task);
|
|||
void RT64UpdateScreen(uint32_t vi_origin);
|
||||
|
||||
std::unordered_map<SDL_Scancode, int> button_map{
|
||||
{ SDL_Scancode::SDL_SCANCODE_LEFT, 0x0002 },
|
||||
{ SDL_Scancode::SDL_SCANCODE_RIGHT, 0x0001 },
|
||||
{ SDL_Scancode::SDL_SCANCODE_UP, 0x0008 },
|
||||
{ SDL_Scancode::SDL_SCANCODE_DOWN, 0x0004 }
|
||||
{ SDL_Scancode::SDL_SCANCODE_LEFT, 0x0002 }, // c left
|
||||
{ SDL_Scancode::SDL_SCANCODE_RIGHT, 0x0001 }, // c right
|
||||
{ SDL_Scancode::SDL_SCANCODE_UP, 0x0008 }, // c up
|
||||
{ SDL_Scancode::SDL_SCANCODE_DOWN, 0x0004 }, // c down
|
||||
{ SDL_Scancode::SDL_SCANCODE_RETURN, 0x1000 }, // start
|
||||
{ SDL_Scancode::SDL_SCANCODE_SPACE, 0x8000 }, // a
|
||||
{ SDL_Scancode::SDL_SCANCODE_LSHIFT, 0x4000 }, // b
|
||||
{ SDL_Scancode::SDL_SCANCODE_Q, 0x2000 }, // z
|
||||
};
|
||||
|
||||
extern int button;
|
||||
|
|
|
@ -2,7 +2,20 @@
|
|||
#include "recomp.h"
|
||||
|
||||
extern "C" void osContInit_recomp(uint8_t* restrict rdram, recomp_context* restrict ctx) {
|
||||
;
|
||||
gpr bitpattern = ctx->r5;
|
||||
gpr status = ctx->r6;
|
||||
MEM_B(0, bitpattern) = 0x01;
|
||||
|
||||
MEM_H(0, status) = 0x0005; // CONT_TYPE_NORMAL
|
||||
MEM_B(2, status) = 0; // controller status
|
||||
MEM_B(3, status) = 0; // controller errno
|
||||
|
||||
// Write CHNL_ERR_NORESP for the other controllers
|
||||
for (size_t controller = 1; controller < 4; controller++) {
|
||||
MEM_B(4 * controller + 3, status) = 0x80;
|
||||
}
|
||||
|
||||
ctx->r2 = 0;
|
||||
}
|
||||
|
||||
extern "C" void osContStartReadData_recomp(uint8_t* restrict rdram, recomp_context* restrict ctx) {
|
||||
|
|
|
@ -64,8 +64,10 @@ void run_thread_function(uint8_t* rdram, uint64_t addr, uint64_t sp, uint64_t ar
|
|||
extern "C" void init(uint8_t * restrict rdram, recomp_context * restrict ctx);
|
||||
|
||||
// rocket robot
|
||||
//extern "C" void game_init(uint8_t* restrict rdram, recomp_context* restrict ctx);
|
||||
extern "C" void game_init(uint8_t* restrict rdram, recomp_context* restrict ctx);
|
||||
// test rom
|
||||
//extern "C" void init(uint8_t * restrict rdram, recomp_context * restrict ctx);
|
||||
|
||||
void do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t dev_address, size_t num_bytes);
|
||||
|
||||
std::unique_ptr<uint8_t[]> rom;
|
||||
|
@ -158,18 +160,18 @@ int main(int argc, char **argv) {
|
|||
// Clear bss
|
||||
// TODO run the entrypoint instead
|
||||
// rocket robot
|
||||
//memset(rdram_buffer.get() + 0xAF860, 0, 0xC00A0u - 0XAF860);
|
||||
memset(rdram_buffer.get() + 0xAF860, 0, 0xC00A0u - 0XAF860);
|
||||
// test rom
|
||||
memset(rdram_buffer.get() + 0x18670, 0, 0x20D120);
|
||||
//memset(rdram_buffer.get() + 0x18670, 0, 0x20D120);
|
||||
|
||||
debug_printf("[Recomp] Starting\n");
|
||||
|
||||
Multilibultra::preinit(rdram_buffer.get(), rom.get());
|
||||
|
||||
// rocket robot
|
||||
// game_init(rdram_buffer.get(), &context);
|
||||
game_init(rdram_buffer.get(), &context);
|
||||
// test rom
|
||||
init(rdram_buffer.get(), &context);
|
||||
//init(rdram_buffer.get(), &context);
|
||||
|
||||
debug_printf("[Recomp] Quitting\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue