PS2 rom0:TESTMODE Launcher v0.2

Discussion in 'PS2 Homebrew' started by VTSTech, Dec 15, 2019.

  1. 330
    413
    97
    VTSTech

    VTSTech Developer

    Joined:
    Apr 8, 2019
    Messages:
    330
    Likes Received:
    413
    Trophy Points:
    97
    Gender:
    Male
    Home Page:
    [​IMG]

    I made a small elf to load rom0:TESTMODE

    Beeps a lot in PCSX2. Gives me color bars and a solid beep on real PS2.

    Just made this to see what it would do.

    PCSX2 Log

    Code:
    loadelf: fname rom0:TESTMODE secname all
    loadelf version 3.30
    Input ELF format filename = rom0:TESTMODE
    0 01000000 0000ed64 .
    Loaded, rom0:TESTMODE
    start address 0x1000008
    gp address 00000000
    # Restart Without Memory Clear.
    # Initialize GS ...
    # Initialize INTC ...
    # Initialize TIMER ...
    # Initialize DMAC ...
    # Initialize VU1 ...
    # Initialize VIF1 ...
    # Initialize GIF ...
    # Initialize VU0 ...
    # Initialize VIF0 ...
    # Initialize IPU ...
    # Initialize FPU ...
    # Initialize Scratch Pad ...
    # Restart Without Memory Clear Done.
    # Restart Without Memory Clear.
    # Initialize GS ...
    # Initialize INTC ...
    # Initialize TIMER ...
    # Initialize DMAC ...
    # Initialize VU1 ...
    # Initialize VIF1 ...
    # Initialize GIF ...
    # Initialize VU0 ...
    # Initialize VIF0 ...
    # Initialize IPU ...
    # Initialize FPU ...
    # Initialize Scratch Pad ...
    # Restart Without Memory Clear Done.
    loadmodule: fname rom0:ADDDRV args 0 arg
    ROM directory not found
    loadmodule: id 27, ret 1
    loadmodule: fname rom0:LIBSD args 0 arg
    loadmodule: id 28, ret 0
    loadmodule: fname rom0:TESTSPU args 0 arg
    iop start end
    loadmodule: id 29, ret 0
    loadmodule: fname rom0:TSIO2MAN args 0 arg
    loadmodule: id 30, ret 0
    loadmodule: fname rom0:TPADMAN args 0 arg
    loadmodule: id 31, ret 0
    read/write allocate memory 4000
    open name rom0:ROMVER flag 1 data 45d78
    open fd = 2
    rom name 0220AC20060210
    NTSC
    voice start...
    Data transfer ...
    TSA = 15512
    kityo
    NTSC 640x448 Inter
    *Unknown Mecacon Command param[0]=90
    Mekacon read error ffffff80
    *Unknown Mecacon Command param[0]=90
    Mekacon read error ffffff80
    *Unknown Mecacon Command param[0]=90
    Mekacon read error ffffff80
    
    testmode.c

    Code:
    //Working Title: 'TESTMODE' Launcher
    //Written by VTSTech ([email protected])
    //Version: 0.3
    
    #include <debug.h>
    #include <iopcontrol.h>
    #include <iopheap.h>
    #include <kernel.h>
    #include <sifrpc.h>
    #include <loadfile.h>
    #include <unistd.h>
    
    //thx sp193
    void ResetIOP()
    {
       SifInitRpc(0);
       while(!SifIopReset("", 0)){};
       while(!SifIopSync()){};
       SifInitRpc(0);
    }
    
    void InitPS2()
    {
       init_scr();
       ResetIOP();
       SifInitIopHeap();
       SifLoadFileInit();
       fioInit();
    }
    
    void banner()
    {
       scr_clear();
      sleep(1);
      scr_printf("===================================== \n");
      scr_printf("=TESTMODE Launcher v0.3===12-22-2019= \n");
      scr_printf("=Written by VTSTech of PSX-Place.com= \n");
      scr_printf("=www.vts-tech.org==================== \n\n");
    }
    
    int main(int argc, char *argv[], char **envp)
    {
       InitPS2();
       banner();
       scr_printf("Launching rom0:TESTMODE in 3 seconds... \n");
       sleep(3);
       LoadExecPS2("rom0:TESTMODE", 0, NULL);
       return 0;
    }
    
    Changelog

    Code:
    v0.3
    Now not loading unnecessary modules
    Removed 1s delay on InitPS2()
    No longer sceCdInit(), removed libcdvd
    
    v0.2
    Added banner
    Added 3s delay so you can see banner
    Package now includes packed/unpacked binary and source code.
    
    v0.1
    First release
     

    Attached Files:

    Last edited: Dec 22, 2019
    TnA, STLcardsWS and jolek like this.
  2. 1,315
    712
    222
    TnA

    TnA Senior Member

    Joined:
    Jul 1, 2018
    Messages:
    1,315
    Likes Received:
    712
    Trophy Points:
    222
    Gender:
    Male
    Location:
    Germany --> Saxony
    If all your smaller Test-ELFs will emerge into a test-app - once upon a/in time -, this is gonna be great! :)
    I think you can reuse the GUI of another app, if you are ever going to do so.
     
    VTSTech likes this.
  3. 1,617
    1,271
    347
    jolek

    jolek Senior Member

    Joined:
    Dec 29, 2017
    Messages:
    1,617
    Likes Received:
    1,271
    Trophy Points:
    347
    Gender:
    Male
    Any chance to add some way to exit from this test screen:
    [​IMG]

    E.g. "Press :but start: to exit?".
     
  4. 330
    413
    97
    VTSTech

    VTSTech Developer

    Joined:
    Apr 8, 2019
    Messages:
    330
    Likes Received:
    413
    Trophy Points:
    97
    Gender:
    Male
    Home Page:
    Once you are there my homebrew is no longer running but the rom0:TESTMODE is. It is it's own application.

    It does seem to display some text to printf in PCSX2, but there isn't anyway to see that text on an actual PS2. Maybe on a TOOL unit...

    These are displayed in PCSX2, and it doesn't come from my homebrew. it comes from TESTMODE

    Code:
    rom name 0220AC20060210
    NTSC
    voice start...
    Data transfer ...
    TSA = 15512
    kityo
    NTSC 640x448 Inter
    Just loading ROMVER wouldn't display the rom name like that, so that is TESTMODE doing that as well.
     
    Last edited: Dec 21, 2019
    TnA and jolek like this.
  5. 768
    1,379
    222
    sp193

    sp193 Developer

    Joined:
    Oct 13, 2014
    Messages:
    768
    Likes Received:
    1,379
    Trophy Points:
    222
    Location:
    Singapore
    Home Page:
    You only have to initialize just what you need. For example, if you have no need to use libcdvd, there is no need to initialize it and you don't need to link your program with it either - doing so, would just make your program larger.

    Similarly, there's no dependency between SIO2MAN and memory card support. So if you do not need memory card support, you could skip loading MCMAN (and MCSERV).

    There should be no need to add sleep() around the program either. What are you waiting for and how do you know exactly how long to wait for?

    Since TESTMODE is in ROM (which is always accessible by default), it should be possible to load and execute it with a 1-liner:
    Code:
    LoadExecPS2("rom0:TESTMODE", 0, NULL);
    
    Internally, LoadExecPS2() will load rom0:EELOAD, which will reboot the IOP and load the ELF. It is a neat way of loading software, but is limited to the devices that the ROM supports.
     
    jolek and TnA like this.
  6. 330
    413
    97
    VTSTech

    VTSTech Developer

    Joined:
    Apr 8, 2019
    Messages:
    330
    Likes Received:
    413
    Trophy Points:
    97
    Gender:
    Male
    Home Page:
    I know MC modules wouldn't be needed, but i try to keep my InitPS2() the same across all my homebrews.

    I thought I had tried a line like that before and it didn't work, I know I tried LoadExecPS2("moduleload", 0, "rom0:TESTMODE"); and that didn't work. the 3 line/arg one did thou. That one line you posted also works.

    I mainly sleep() to prevent unusual behaviors or to let the user see something that would just blink otherwise.
     

Share This Page