diff --git a/code/duffle/bios.h b/code/duffle/bios.h new file mode 100644 index 0000000..1946132 --- /dev/null +++ b/code/duffle/bios.h @@ -0,0 +1,14 @@ +#ifdef INTELLISENSE_DIRECTIVES +# pragma once +#endif +enum { + bios_init_pad_2 = 0x12, + bios_start_pad_2 = 0x13, + bios_flushcache = 0x44, + bios_table_addr = 0xA0, + bios_btable_addr = 0xB0, +}; + +enum { + bios_pad_buffer_size = 0x22, +}; diff --git a/code/duffle/dsl.h b/code/duffle/dsl.h index 1ed754b..f01b0a6 100644 --- a/code/duffle/dsl.h +++ b/code/duffle/dsl.h @@ -28,8 +28,9 @@ #define internal static // internal #define asm __asm__ -#define align_(value) __attribute__((aligned (value))) // for easy alignment +#define A_(data) (& data) +#define align_(value) __attribute__((aligned (value))) // for easy alignment #define align_(value) __attribute__((aligned (value))) // for easy alignment #define C_(type,data) ((type)(data)) // for enforced precedence #define expect_(x, y) __builtin_expect(x, y) // so compiler knows the common path diff --git a/code/duffle/gen/macs.h b/code/duffle/gen/macs.h index cfdfa9e..e2c9069 100644 --- a/code/duffle/gen/macs.h +++ b/code/duffle/gen/macs.h @@ -14,6 +14,7 @@ // source: C:\projects\Pikuma\ps1\code\duffle\pad.h // source: C:\projects\Pikuma\ps1\code\duffle\dsl.atom.h // source: C:\projects\Pikuma\ps1\code\duffle\lottes_tape.h +// source: C:\projects\Pikuma\ps1\code\duffle\bios.h // source: C:\projects\Pikuma\ps1\code\duffle\psyq.h // source: C:\projects\Pikuma\ps1\code\duffle\math.atom.c // source: C:\projects\Pikuma\ps1\code\duffle\mips.atom.c diff --git a/code/duffle/gen/offsets.h b/code/duffle/gen/offsets.h index 991cddf..4417594 100644 --- a/code/duffle/gen/offsets.h +++ b/code/duffle/gen/offsets.h @@ -11,6 +11,7 @@ // source: C:\projects\Pikuma\ps1\code\duffle\pad.h // source: C:\projects\Pikuma\ps1\code\duffle\dsl.atom.h // source: C:\projects\Pikuma\ps1\code\duffle\lottes_tape.h +// source: C:\projects\Pikuma\ps1\code\duffle\bios.h // source: C:\projects\Pikuma\ps1\code\duffle\psyq.h // source: C:\projects\Pikuma\ps1\code\duffle\math.atom.c // source: C:\projects\Pikuma\ps1\code\duffle\mips.atom.c diff --git a/code/duffle/mips.atom.c b/code/duffle/mips.atom.c index d7bfc89..e50f79d 100644 --- a/code/duffle/mips.atom.c +++ b/code/duffle/mips.atom.c @@ -1,6 +1,7 @@ #ifdef INTELLISENSE_DIRECTIVES # include "gen/macs.h" # include "gen/offsets.h" +# include "bios.h" # include "lottes_tape.h" #endif @@ -8,11 +9,6 @@ ATOM_FILE_DEBUGGER_LINE_MARKER(mips_atom_c); #pragma region Baked Atoms -enum { - bios_flushcache = 0x44, - bios_table_addr = 0xA0, -}; - /* Flushes the Instruction Cache (PSX A-function 0x44 via BIOS stub at 0xA0). * Sequence (per MIPS ABI; arguments in arg registers, RA pushed to stack): * 1. sp -= 8; sw $ra, 4($sp) ; save RA diff --git a/code/hello_camera/hello_camera.c b/code/hello_camera/hello_camera.c index ebbdaa0..b2ed29b 100644 --- a/code/hello_camera/hello_camera.c +++ b/code/hello_camera/hello_camera.c @@ -26,6 +26,7 @@ #include "duffle/dsl.atom.h" #include "duffle/lottes_tape.h" +#include "duffle/bios.h" #include "duffle/psyq.h" #pragma endregion Duffle Headers @@ -115,10 +116,10 @@ NI_ void pad_bios_init_start(PadBiosRaw* raw0, PadBiosRaw* raw1) asm volatile( asm_words( or_u( rarg_2, rarg_1, rdiscard), /* $a2 = $a1 = raw1 */ - add_ui( rarg_1, rdiscard, 0x22), /* $a1 = 0x22 */ - add_ui( rarg_3, rdiscard, 0x22), /* $a3 = 0x22 */ - add_ui( rtmp_1, rdiscard, 0x12), /* $t1 = 0x12 */ - add_ui( rtmp_2, rdiscard, 0xB0), /* $t2 = 0xB0 */ + add_ui( rarg_1, rdiscard, bios_pad_buffer_size), /* $a1 = 0x22 */ + add_ui( rarg_3, rdiscard, bios_pad_buffer_size), /* $a3 = 0x22 */ + add_ui( rtmp_1, rdiscard, bios_init_pad_2), /* $t1 = 0x12 */ + add_ui( rtmp_2, rdiscard, bios_btable_addr), /* $t2 = 0xB0 */ call_reg(rtmp_2), /* jalr $t2, $ra */ nop /* BD slot */ ) @@ -140,8 +141,8 @@ NI_ void pad_bios_init_start(PadBiosRaw* raw0, PadBiosRaw* raw1) /* B(13h) StartPAD2() — no args. The BIOS preserves $sp. */ asm volatile( asm_words( - add_ui( rtmp_1, rdiscard, 0x13), /* $t1 = 0x13 */ - add_ui( rtmp_2, rdiscard, 0xB0), /* $t2 = 0xB0 (re-load) */ + add_ui( rtmp_1, rdiscard, bios_start_pad_2), /* $t1 = 0x13 */ + add_ui( rtmp_2, rdiscard, bios_btable_addr), /* $t2 = 0xB0 (re-load) */ call_reg(rtmp_2), /* jalr $t2, $ra */ nop /* BD slot */ )