<commit_before>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <math.h>

#include <rsx/commands.h>
#include <rsx/nv40.h>

#include <io/pad.h>

#include <sysmodule/sysmodule.h>

#include "ball.bin.h"
#include "texture.h"
#include "rsxutil.h"
#include "nv_shaders.h"

int currentBuffer = 0;
realityTexture *ball; // Texture.

void drawFrame(int buffer, long frame) {

	setupRenderTarget(buffer);

	realityViewportTranslate(context, 0.0, 0.0, 0.0, 0.0);
	realityViewportScale(context, 1.0, 1.0, 1.0, 0.0); 

	realityZControl(context, 0, 1, 1); // disable viewport culling

	// Enable alpha blending.
	realityBlendFunc(context,
		NV30_3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA |
		NV30_3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
		NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA |
		NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO);
	realityBlendEquation(context, NV40_3D_BLEND_EQUATION_RGB_FUNC_ADD |
		NV40_3D_BLEND_EQUATION_ALPHA_FUNC_ADD);
	realityBlendEnable(context, 1);

	realityViewport(context, res.width, res.height);

	// Just because we can only set the clear color, dosen't mean it has to be boring
	double cycle = (frame % 200)/100.0;
	uint8_t color = (sin(cycle*M_PI) + 1.0) * 127 ;

	// set the clear color
	realitySetClearColor(context, color << 8 | color << 16); 
	// and the depth clear value
	realitySetClearDepthValue(context, 0xffff);
	// Clear the buffers
	realityClearBuffers(context, REALITY_CLEAR_BUFFERS_COLOR_R |
				     REALITY_CLEAR_BUFFERS_COLOR_G |
				     REALITY_CLEAR_BUFFERS_COLOR_B |
				     REALITY_CLEAR_BUFFERS_DEPTH);

	realityLoadVertexProgram(context, &nv40_vp);
	realityLoadFragmentProgram(context, &nv30_fp);
}

void unload_modules() {
	SysUnloadModule(SYSMODULE_PNGDEC);
	SysUnloadModule(SYSMODULE_FS);<commit_msg>Textures and vertexes, now lets see if it will run.<commit_after>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <math.h>

#include <rsx/commands.h>
#include <rsx/nv40.h>

#include <io/pad.h>

#include <sysmodule/sysmodule.h>

#include "ball.bin.h"
#include "texture.h"
#include "rsxutil.h"
#include "nv_shaders.h"

int currentBuffer = 0;
realityTexture *ball; // Texture.

void drawFrame(int buffer, long frame) {

	setupRenderTarget(buffer);

	realityViewportTranslate(context, 0.0, 0.0, 0.0, 0.0);
	realityViewportScale(context, 1.0, 1.0, 1.0, 0.0); 

	realityZControl(context, 0, 1, 1); // disable viewport culling

	// Enable alpha blending.
	realityBlendFunc(context,
		NV30_3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA |
		NV30_3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA,
		NV30_3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA |
		NV30_3D_BLEND_FUNC_DST_ALPHA_ZERO);
	realityBlendEquation(context, NV40_3D_BLEND_EQUATION_RGB_FUNC_ADD |
		NV40_3D_BLEND_EQUATION_ALPHA_FUNC_ADD);
	realityBlendEnable(context, 1);

	realityViewport(context, res.width, res.height);

	// Just because we can only set the clear color, dosen't mean it has to be boring
	double cycle = (frame % 200)/100.0;
	uint8_t color = (sin(cycle*M_PI) + 1.0) * 127 ;

	// set the clear color
	realitySetClearColor(context, color << 8 | color << 16); 
	// and the depth clear value
	realitySetClearDepthValue(context, 0xffff);
	// Clear the buffers
	realityClearBuffers(context, REALITY_CLEAR_BUFFERS_COLOR_R |
				     REALITY_CLEAR_BUFFERS_COLOR_G |
				     REALITY_CLEAR_BUFFERS_COLOR_B |
				     REALITY_CLEAR_BUFFERS_DEPTH);

	// Load shaders, because the rsx won't do anything without them.
	realityLoadVertexProgram(context, &nv40_vp);
	realityLoadFragmentProgram(context, &nv30_fp);

	// Load texture
	realitySetTexture(context, 0, ball);

	// Generate quad
	realityVertexBegin(context, REALITY_QUADS);
	{
		realityTexCoord2f(context, 0.0, 0.0);
		realityVertex4f(context, 600.0, 300.0, 0.0, 1.0); 

		realityTexCoord2f(context, 1.0, 0.0);
		realityVertex4f(context, 1112.0, 300.0, 0.0, 1.0); 

		realityTexCoord2f(context, 1.0, 1.0);
		realityVertex4f(context, 1112.0, 812.0, 0.0, 1.0); 

		realityTexCoord2f(context, 0.0, 1.0);
		realityVertex4f(context, 600.0, 812.0, 0.0, 1.0); 
	}
	realityVertexEnd(context);
}

void unload_modules() {
	SysUnloadModule(SYSMODULE_PNGDEC);
	SysUnloadModule(SYSMODULE_FS);
{'fraction_non_alphanumeric': 0.11855547636018056, 'fraction_numerical': 0.04727963886909004, 'mean_word_length': 5.083815028901734, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6933903', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1690, 'n_words': 322}