Skip to content

Commit f9ba284

Browse files
committed
My Triangle (and other files)
1 parent 1a5a576 commit f9ba284

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

.clang-format

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 4
3+
ColumnLimit: 0
4+
NamespaceIndentation: All
5+
SortIncludes: false

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "external/libtp_c"]
22
path = external/libtp_c
33
url = https://github.com/hallcristobal/libtp_c.git
4+
[submodule "external/gcn_c"]
5+
path = external/gcn_c
6+
url = https://github.com/hallcristobal/gcn_c.git

Romhack.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ map = "build/GZ2E01.map"
1414
iso = "build/tpgz.iso"
1515

1616
[link]
17-
entries = ["game_loop", "read_controller"]
17+
entries = ["game_loop", "read_controller", "draw"]
1818
base = "0x8046_0000"
19-
libs = ["tpgz.a", "external/libtp_c/libtp_c.a"]
19+
libs = ["tpgz.a", "external/libtp_c/libtp_c.a", "external/gcn_c/gcn_c.a"]

external/gcn_c

Submodule gcn_c added at ea57b7f

patch.asm

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
; with inject at 0x80460000 gives us 0xA7BE0 bytes
44
u32 0x3c608050
55

6+
0x802e7648:
7+
b draw
8+
69
0x80006444:
710
bl game_loop
811
bl fapGm_Execute()

src/lib.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "libtp_c/include/controller.h"
33
#include "libtp_c/include/system.h"
44
#include "libtp_c/include/tp.h"
5+
#include "gcn_c/include/gfx.h"
56

67
static bool visible = false;
78

@@ -24,4 +25,26 @@ extern "C" void game_loop() {
2425
} else if (l_down && r_down && z_down && a_down) {
2526
visible = true;
2627
}
28+
}
29+
30+
extern "C" void draw() {
31+
GX_SetBlendMode(GX_BM_BLEND, GX_BL_ONE, GX_BL_ONE, GX_LO_SET);
32+
33+
GX_ClearVtxDesc();
34+
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
35+
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
36+
37+
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_NRM_XYZ, GX_F32, 0);
38+
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
39+
40+
GX_Begin(GX_TRIANGLES, GX_VTXFMT0, 3);
41+
{
42+
GX_Position2f32(150.0f, 150.0f);
43+
GX_Color1u32(0xFF0000FF);
44+
GX_Position2f32(250.0f, 150.0f);
45+
GX_Color1u32(0x00FF00FF);
46+
GX_Position2f32(200.0f, 250.0f);
47+
GX_Color1u32(0x0000FFFF);
48+
}
49+
GX_End();
2750
}

0 commit comments

Comments
 (0)