gif_sender migration #1 (libspacket)

This commit is contained in:
h4570
2020-11-16 18:48:36 +01:00
parent c1ad6effbd
commit 7e442bcf5c
2 changed files with 29 additions and 27 deletions
@@ -17,6 +17,7 @@
#include <draw_primitives.h> #include <draw_primitives.h>
#include <math3d.h> #include <math3d.h>
#include <packet.h> #include <packet.h>
#include <spacket.h>
#include "../models/mesh.hpp" #include "../models/mesh.hpp"
#include "../models/math/matrix.hpp" #include "../models/math/matrix.hpp"
#include "../models/screen_settings.hpp" #include "../models/screen_settings.hpp"
+28 -27
View File
@@ -54,37 +54,38 @@ GifSender::~GifSender()
/** Send texture via GIF */ /** Send texture via GIF */
void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer) void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
{ {
const u16 packetSize = 40; spacket_t *spacket = spacket_create(15, SPACKET_NORMAL);
packet_t *packet = packet_init(packetSize, PACKET_NORMAL); spacket_update(
qword_t *q = packet->data; spacket,
q = draw_texture_transfer(q, texture.getData(), texture.getWidth(), texture.getHeight(), GS_PSM_24, t_texBuffer->address, t_texBuffer->width); draw_texture_transfer(
DMATAG_CNT(q, 2, 0, 0, 0); spacket->base,
q++; texture.getData(),
q = draw_texture_wrapping(q, 0, texture.getWrapSettings()); texture.getWidth(),
q = draw_texture_flush(q); texture.getHeight(), GS_PSM_24,
FlushCache(0); t_texBuffer->address,
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0); t_texBuffer->width));
dma_wait_fast(); spacket_chain_open_cnt(spacket, 0, 0, 0);
packet_free(packet); spacket_update(spacket, draw_texture_wrapping(spacket->next, 0, texture.getWrapSettings()));
spacket_chain_close_tag(spacket);
spacket_update(spacket, draw_texture_flush(spacket->next));
spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true);
spacket_free(spacket);
} }
void GifSender::sendClear(zbuffer_t *t_zBuffer) void GifSender::sendClear(zbuffer_t *t_zBuffer)
{ {
packet_t *packet = packet_init(100, PACKET_NORMAL); spacket_t *spacket = spacket_create(36, SPACKET_NORMAL);
qword_t *q = packet->data; spacket_chain_open_end(spacket, 0, 0);
q++; spacket_update(spacket, draw_disable_tests(spacket->next, 0, t_zBuffer));
q = draw_disable_tests(q, 0, t_zBuffer); spacket_update(spacket, draw_clear(spacket->next, 0,
q = draw_clear(q, 0, 2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2), screen->width, screen->height,
screen->width, screen->height, 0x10, 0x10, 0x10));
0x10, 0x10, 0x10); spacket_update(spacket, draw_enable_tests(spacket->next, 0, t_zBuffer));
q = draw_enable_tests(q, 0, t_zBuffer); spacket_update(spacket, draw_finish(spacket->next));
q = draw_finish(q); spacket_chain_close_tag(spacket);
DMATAG_END(packet->data, q - packet->data - 1, 0, 0, 0); spacket_send_chain(spacket, DMA_CHANNEL_GIF, true, true);
FlushCache(0); spacket_free(spacket);
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
dma_wait_fast();
packet_free(packet);
} }
/** Used in game loop. /** Used in game loop.