Spyro 1 Reverse Engineering
Decompilation of functions from Spyro 1 into human readable C
 
Loading...
Searching...
No Matches
draw_stuff.c
Go to the documentation of this file.
1#include <common.h>
2#include <custom_types.h>
3#include <moby.h>
4#include <shapes.h>
5
22void DrawPrimitive(void* primitive)
23
24{
25 int* local_gfx_ptrs;
26 short* unk_first_gfx_ptr;
27
28 local_gfx_ptrs = _ptr_arrayGraphicsRelatedPointers;
29 unk_first_gfx_ptr = (short*) *_ptr_arrayGraphicsRelatedPointers;
30 *_ptr_arrayGraphicsRelatedPointers = (int*)primitive;
31 if (unk_first_gfx_ptr != 0x0) {
32 *unk_first_gfx_ptr = (short)primitive;
33 *(char *)(unk_first_gfx_ptr + 1) = (char)((uint)primitive >> 0x10);
34 return;
35 }
36 local_gfx_ptrs[1] = (int*)primitive;
37 return;
38}
39
40
55void DrawArrow(HudMobyInfo* hudMobyInfo, uint timer, int leftOrRightArrow)
56{
57 if ((timer % 32) < 16) // Alternate from being visible, and not every 16 frames
58 {
59 _ptr_hudMobys = _ptr_hudMobys - sizeof(Moby); // Make space in the array of moby structs to be drawn to the hud
60 memset(_ptr_hudMobys,'\0', sizeof(Moby)); // 0 out the area
61
62 ((Moby*) _ptr_hudMobys)->type = 0x105; // Set Moby Type to the ascii number 1 for an arrow
63
64 Vec3Copy(&((Moby*) _ptr_hudMobys)->position, hudMobyInfo); // Set Moby Position from info struct (Z represents size/depth in 2D)
65
66 if (leftOrRightArrow < 2) {
67 ((Moby*) _ptr_hudMobys)->rotation.x = 64; // Setting default roll rotation for a right arrow
68 ((Moby*) _ptr_hudMobys)->rotation.z = (byte)(leftOrRightArrow * 128); // Bitshifting the arrow choice by 7 (multiplying by 128) to result in
69 // the yaw rotation of the number 1 to a left arrow.
70 }
71 ((Moby*) _ptr_hudMobys)->requiredHUD1 = 0x7f; // Required for hud? Must be positive
72 ((Moby*) _ptr_hudMobys)->color = MOBY_COLOR_GOLD; // Setting the color to gold
73 ((Moby*) _ptr_hudMobys)->requiredHUD2 = -1; // Required for hud 2? Must be negative
74 }
75 return;
76}
77
78
94void DrawTextbox(int xBound1,int xBound2,int yBound1,int yBound2)
95{
97
98 PrimitiveAlphaHack(_ptr_primitivesArray,1,0,0x40,0); // Trasparent black background hack
99 DrawPrimitive(ptr_prim);
100 ptr_prim->tag = 0x5000000;
101 ptr_prim->code = POLY4F_TRANSPARENT;
102 ptr_prim->point1Pos.x = xBound1;
103 ptr_prim->point2Pos.x = xBound2;
104 ptr_prim->point3Pos.x = xBound1;
105 ptr_prim->point4Pos.x = xBound2;
106 ptr_prim->point1Pos.y = yBound1;
107 ptr_prim->point2Pos.y = yBound1;
108 ptr_prim->point3Pos.y = yBound2;
109 ptr_prim->point4Pos.y = yBound2;
110 ptr_prim->color.R = 0x70;
111 ptr_prim->color.G = 0x70;
112 ptr_prim->color.B = 0x70;
113 DrawPrimitive((byte*)ptr_prim + 0xC);
114 _ptr_primitivesArray = (byte*)ptr_prim + 0x24; // Make space in the array of primitives for the next one
115
116 // Outline of textbox
117 DrawLine(xBound1,yBound1,xBound2,yBound1);
118 DrawLine(xBound2,yBound1,xBound2,yBound2);
119 DrawLine(xBound2,yBound2,xBound1,yBound2);
120 DrawLine(xBound1,yBound2,xBound1,yBound1);
121 return;
122}
123
124 // end of reveresed_functions
unsigned char byte
unsigned int uint
void PrimitiveAlphaHack(void *param_1, int param_2, int param_3, short colorSpace, int param_5)
This is a weird hack that seems to be related to transparency for primitaves? Address: 0x80060670.
void DrawLine(int point1X, int point1Y, int point2X, int point2Y)
Draws a golden line to the screen Address: 0x8001844c.
char * _ptr_hudMobys
int * _ptr_primitivesArray
int * _ptr_arrayGraphicsRelatedPointers
void memset(void *str, int c, int n)
void DrawArrow(HudMobyInfo *hudMobyInfo, uint timer, int leftOrRightArrow)
Draws a blinking arrow facing left or right.
Definition draw_stuff.c:55
void DrawTextbox(int xBound1, int xBound2, int yBound1, int yBound2)
Draws a black textbox with a gold border. You can specify the bounds.
Definition draw_stuff.c:94
void DrawPrimitive(void *primitive)
Draws a ps1 primitive to the screen.
Definition draw_stuff.c:22
void Vec3Copy(int *dst, int *src)
Copies the 'src' Vector to the 'dst' Vector.
Definition vector.c:47
@ MOBY_COLOR_GOLD
Definition moby.h:66
@ POLY4F_TRANSPARENT
Definition shapes.h:22
This is the main moby/object struct.
Definition moby.h:151
FOR IN GAME.
Definition shapes.h:224
struct Vec2_u16 point4Pos
Definition shapes.h:237
struct Vec2_u16 point1Pos
Definition shapes.h:234
struct Vec2_u16 point3Pos
Definition shapes.h:236
char code
Definition shapes.h:232
RGB_u8 color
Definition shapes.h:231
struct Vec2_u16 point2Pos
Definition shapes.h:235
unsigned char R
Definition common.h:195
unsigned char B
Definition common.h:197
unsigned char G
Definition common.h:196
unsigned short y
Definition vector.h:48
unsigned short x
Definition vector.h:47