# TrueReality - native code documentation                               #
# Copyright (C) 1999 Niki W. Waibel                                     #
#                                                                       #
# This program is free software; you can redistribute it and/           #
# or modify it under the terms of the GNU General Public Li-            #
# cence as published by the Free Software Foundation; either            #
# version 2 of the Licence, or any later version.                       #
#                                                                       #
# This program is distributed in the hope that it will be use-          #
# ful, but WITHOUT ANY WARRANTY; without even the implied war-          #
# ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         #
# See the GNU General Public Licence for more details.                  #
#                                                                       #
# You should have received a copy of the GNU General Public             #
# Licence along with this program; if not, write to the Free            #
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,         #
# USA.                                                                  #
#                                                                       #
# Information about me (the author):                                    #
#   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE       #
#   niki.waibel@gmx.net                                                 #


=========================================================================
             This is some sort of native code documentation.
=========================================================================


All of this stuff was figured out by disassembling/emulating various demos
with TrueReality.
All things which I'm not sure about are marked with a '?'.





General things:
 o Native code means executing
    + real c functions (may depend on the c compiler if not ANSI)
    + real library functions (depend on the operating system)
   instead of emulating each cpu opcode.




Current native routines:

        NAME

        CODE (hex)      CODE (dis listing)



        void set_sr()

        40846000        MTC0    r04, cpr[0][STATUS]
        00000000        SLL     r00, r00, $00
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00



        void get_sr()

        40026000        MFC0    r02, cpr[0][STATUS]
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00



        disable_interrupts()

        40086000        MFC0    r08, cpr[0][STATUS]
        2401fffe        ADDIU   r01, r00, $fffe
        01014824        AND     r09, r08, r01
        40896000        MTC0    r09, cpr[0][STATUS]
        31020001        ANDI    r02, r08, $0001
        00000000        SLL     r00, r00, $00
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00



        restore_interrupts()

        40086000        MFC0    r08, cpr[0][STATUS]
        01044025        OR      r08, r08, r04
        40886000        MTC0    r08, cpr[0][STATUS]
        00000000        SLL     r00, r00, $00
        00000000        SLL     r00, r00, $00
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00



        set_vi_mode()

        27bdffd8        ADDIU   r29, r29, $ffd8 (-40)
        afbf001c        SW      r31, $0001c(r29)
        afa40028        SW      r04, $00028(r29)
        0c080574        JAL     disable_interrupts
        afb00018        SW      r16, $00018(r29)
        3c0f8020        LUI     r15, $8020
        8def50ac        LW      r15, $050ac(r15)
        8fae0028        LW      r14, $00028(r29)
        3c198020        LUI     r25, $8020
        24180001        ADDIU   r24, r00, $0001
        adee0008        SW      r14, $00008(r15)
        8f3950ac        LW      r25, $050ac(r25)
        3c088020        LUI     r08, $8020
        00408025        OR      r16, r02, r00
        a7380000        SH      r24, $00000(r25)
        8d0850ac        LW      r08, $050ac(r08)
        02002025        OR      r04, r16, r00
        8d090008        LW      r09, $00008(r08)
        8d2a0004        LW      r10, $00004(r09)
        0c08057c        JAL     restore_interrupts
        ad0a000c        SW      r10, $0000c(r08)
        8fbf001c        LW      r31, $0001c(r29)
        8fb00018        LW      r16, $00018(r29)
        27bd0028        ADDIU   r29, r29, $0028 (40)
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00



        swap_vi_buffer()

        27bdffe0        ADDIU   r29, r29, $ffe0 (-32)
        afbf0014        SW      r31, $00014(r29)
        0c080574        JAL     disable_interrupts
        afa40020        SW      r04, $00020(r29)
        3c0f8020   !!   LUI     r15, $8020
        8def50ac   !!   LW      r15, $050ac(r15)
        8fae0020        LW      r14, $00020(r29)
        afa2001c        SW      r02, $0001c(r29)
        3c188020        LUI     r24, $8020
        adee0004        SW      r14, $00004(r15)
        8f1850ac        LW      r24, $050ac(r24)
        97190000        LHU     r25, $00000(r24)
        37280010        ORI     r08, r25, $0010
        a7080000        SH      r08, $00000(r24)
        0c08057c        JAL     restore_interrupts
        8fa4001c        LW      r04, $0001c(r29)
        8fbf0014        LW      r31, $00014(r29)
        27bd0020        ADDIU   r29, r29, $0020 (32)
        03e00008        JR      r31
        00000000        SLL     r00, r00, $00
        
