diff --git a/config/regions.tsv b/config/regions.tsv index 91911e8..11d8bec 100644 --- a/config/regions.tsv +++ b/config/regions.tsv @@ -125,6 +125,7 @@ 0x80058288 0x800582AC src/func_80058288.c 0x8005E3D0 0x8005E3F4 src/func_8005E3D0.c 0x8005ED6C 0x8005EDBC src/func_8005ED6C.c +0x80065930 0x80065980 src/func_80065930.c 0x80065B6C 0x80065B8C src/func_80065B6C.c 0x800668A8 0x800668F0 src/func_800668A8.c 0x800681A4 0x800681E0 src/func_800681A4.c diff --git a/src/func_80065930.c b/src/func_80065930.c new file mode 100644 index 0000000..627671f --- /dev/null +++ b/src/func_80065930.c @@ -0,0 +1,51 @@ +/* func_80065930 — 0x80065930..0x80065980 (80 bytes). + * + * Searches a 30-entry key table (0x80132AF8) for the argument; returns the + * value at the matching index in the value table (0x80132A80), else 0. + * + * Original words: + * 0x3C068013 lui a2,0x8013 + * 0x24C62A80 addiu a2,a2,10880 ; a2 = &value[0] (0x80132A80) + * 0x3C038013 lui v1,0x8013 + * 0x24632AF8 addiu v1,v1,11000 ; v1 = &key[0] (0x80132AF8) + * loop: + * 0x8C620000 lw v0,0(v1) + * 0x00000000 nop + * 0x14440004 bne v0,a0,next ; if (key[i] != arg) next + * 0x00000000 nop + * 0x8CC20000 lw v0,0(a2) + * 0x0801965E j done + * 0x00000000 nop + * next: + * 0x24C60004 addiu a2,a2,4 + * 0x24A50001 addiu a1,a1,1 ; i++ + * 0x28A2001E slti v0,a1,30 + * 0x1440FFF5 bnez v0,loop + * 0x24630004 addiu v1,v1,4 ; (delay) next key + * 0x00001021 move v0,zero + * done: + * 0x03E00008 jr ra + * 0x00000000 nop + * + * Unlike 0x80042CE0 (which used one walked register for both arrays), here + * two separate walked pointers a2/v1 advance in the branch delay slots. The + * not-found path returns 0 via a separate move. + * + * LIMITS: table sizes (30), 4-byte stride, and the key/value split are + * hypotheses read from the loop geometry. Only the compiled bytes are + * evidence. + */ + +extern int D_80132A80[]; +extern int D_80132AF8[]; + +int func_80065930(int key) +{ + int i; + + for (i = 0; i < 30; i++) { + if (D_80132AF8[i] == key) + return D_80132A80[i]; + } + return 0; +} \ No newline at end of file