• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Research: [RUBY] IV/EV Viewer

  • 249
    Posts
    12
    Years
    • Seen Jun 17, 2024
    Goodmorning everyone.
    Today i would like to release the code of a feature that i developed a few days ago, that is a "visualizer" of IV/EV of the pokémon of our team.
    Since this implementation is quite complex, i decided to abandon the ASM and develop it entirely in C.
    Here is the code:
    Spoiler:

    The gba_types.h and gba_keys.h libraries can be found at the following link: : https://github.com/shinyquagsire23/FR-CrystalIntro/tree/master/include

    Before showing you the implementation in operation, i would like to explain to you broadly how the code works:
    At the beginning of the code there are the declarations of some useful offsets that we will use later.
    The most important are StartROM, which will contain the offset in which you will insert the compiled code and STATS, a table that will contain the pointers and the coordinates of the strings representing each statistic (hp, atk, def, sp.atk, sp.def, speed).
    The table follows the following format [pointer][Y_cord][X_cord], with fields of 32bit, 16bit and 16bit respectively.
    For convenience, i report the table i used:
    EB F7 40 08 10 00 98 00 D9 F7 40 08 38 00 C8 00
    E0 F7 40 08 58 00 C8 00 D5 F7 40 08 70 00 90 00
    DD F7 40 08 58 00 58 00 E5 F7 40 08 38 00 58 00
    Other important definitions are DEFAULT and ISTO.
    The first definition, DEFAULT, allows you to choose which graphics apply to the menu.
    If left at 0, the menu will have BW-style graphics, otherwise the standard ruby graphics will be loaded.
    The second definition, ISTO, allows you to choose what will be the IV/EV display mode.
    If left at 0, the display mode will be the graph with the expansion, otherwise the histogram will be loaded.
    You can leave the other definitions unchanged.
    Soon after, we find the declarations of all the prototypes of the functions that we are going to use.

    From this point forward, there is the actual code of our implementation.
    Inside the main the sprite of the first pokémon in the squad is displayed and the TIMER is set to 0.
    Subsequently, the code of the second main is called.
    The TIMER i mentioned earlier will be used in the second main to scan two different phases:
    - the first, in which we will correct the sprite palette shown above.
    - the second, in which there is the part of the code that will take care of the input of the keys.
    By pressing the UP/DOWN, you can view each member of your team.
    By pressing the RIGHT/LEFT, it's possible to change the data that will be displayed, changing from IV to EV or the other way around.
    Finally, by pressing the B key, the menu will be closed.

    Whenever one of the arrow keys is pressed, the information will be refreshed by calling the refreshInfo() function.
    After printing the various menu strings, the data of the pokémon you are trying to view is read.
    Subsequently, based on the values read, the points of the statistics graph are calculated.
    These points are saved in a 2x7 matrix called "points".
    The final additional element is used to have a "cyclical reference" when the matrix will be scanned by the for loop (the first and last points are equal).
    To obtain the "expansion" effect of the graph, the code use a matrix of similar dimensions called progressPoints.
    Using the for loop mentioned above, a temporary graph is drawn at each iteration.
    This process will be repeated until all the points in the progressPoints matrix are the same as those contained in points (final graph).

    The code will also load some graphic parts necessary for the correct display of the menu.
    Inside the code there are the strings XXXXXX, YYYYYY, ZZZZZZ, KKKKKK, JJJJJJ.
    These will be replaced with the offsets containing the data of the palettes, raws and tiles that you will use within the menu.
    For convenience, i report the ones that i've used:
    Spoiler:


    The topic has been published as "research", since i think the code can be improved.
    In fact, the current version is very slow due to the numerous calculations that the CPU must perform to draw the lines of the graph.
    Here is a video with the working implementation:
     
    Last edited:
    After working on code optimization, i was able to significantly speed up the expansion of the graph:
    [PokeCommunity.com] [RUBY] IV/EV Viewer

    In addition, a new display mode has been developed, a sort of histogram:
    [PokeCommunity.com] [RUBY] IV/EV Viewer

    Finally, the code has been structured so that you can decide which display mode and graphics use based on the value of a couple of definitions at the beginning of the file:
    #define DEFAULT 0
    #define ISTO 0
    The first definition, DEFAULT, allows you to choose which graphics apply to the menu.
    If left at 0, the menu will have BW-style graphics, otherwise the standard ruby graphics will be loaded.
    The second definition, ISTO, allows you to choose what will be the IV/EV display mode.
    If left at 0, the display mode will be the graph with the expansion, otherwise the histogram will be loaded.
    The new version of the code will available in the next few days.
     
    Last edited:
    Updated code in main post.
    The new changes are the ones listed in the previous message.
     
    Back
    Top