"Fixed" implementation of lwl/swl (fixes initial test games), implemented more controller functionality

This commit is contained in:
Mr-Wiseguy 2022-11-20 22:56:13 -05:00
parent aad1bac933
commit 6e45fac005
7 changed files with 1271 additions and 685 deletions

View file

@ -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) {

View file

@ -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");