pizza: change internal rendering pipeline to 32 bit colors

This commit is contained in:
nattthebear 2017-06-16 09:20:35 -04:00
parent 04d4880564
commit a4c6d04a18
4 changed files with 777 additions and 885 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,6 @@ typedef void (*gpu_frame_ready_cb_t) ();
/* prototypes */
void gpu_dump_oam();
uint16_t *gpu_get_frame_buffer();
void gpu_init(gpu_frame_ready_cb_t cb);
void gpu_reset();
void gpu_set_speed(char speed);
@ -105,27 +104,26 @@ typedef struct gpu_s
uint_fast16_t frame_counter;
/* BG palette */
uint16_t bg_palette[4];
uint32_t bg_palette[4];
/* Obj palette 0/1 */
uint16_t obj_palette_0[4];
uint16_t obj_palette_1[4];
uint32_t obj_palette_0[4];
uint32_t obj_palette_1[4];
/* CGB palette for background */
uint16_t cgb_palette_bg_rgb565[0x20];
uint32_t cgb_palette_bg_rgb888[0x20];
uint16_t cgb_palette_bg[0x20];
uint8_t cgb_palette_bg_idx;
uint8_t cgb_palette_bg_autoinc;
/* CGB palette for sprites */
uint16_t cgb_palette_oam_rgb565[0x20];
uint32_t cgb_palette_oam_rgb888[0x20];
uint16_t cgb_palette_oam[0x20];
uint8_t cgb_palette_oam_idx;
uint8_t cgb_palette_oam_autoinc;
/* frame buffer */
uint16_t frame_buffer_prev[160 * 144];
uint16_t frame_buffer[160 * 144];
uint32_t frame_buffer[160 * 144];
uint8_t priority[160 * 144];
uint8_t palette_idx[160 * 144];
} gpu_t;

View File

@ -1,8 +0,0 @@
//
// Created by DVDN on 14/07/2016.
//
#ifndef PIZZABOY_TESTONE_H
#define PIZZABOY_TESTONE_H
#endif //PIZZABOY_TESTONE_H

View File

@ -38,7 +38,7 @@
#include "sound_output.h"
/* proto */
void cb();
void frame_cb();
void connected_cb();
void disconnected_cb();
void rumble_cb(uint8_t rumble);
@ -46,12 +46,6 @@ void network_send_data(uint8_t v);
void *start_thread(void *args);
void *start_thread_network(void *args);
/* frame buffer pointer */
uint16_t *fb;
/* magnify rate */
float magnify_rate = 1.f;
/* cartridge name */
char cart_name[64];
@ -73,21 +67,16 @@ EXPORT int Init(const void *rom, int romlen)
gameboy_init();
/* init GPU */
gpu_init(&cb);
gpu_init(frame_cb);
/* set rumble cb */
mmu_set_rumble_cb(&rumble_cb);
/* get frame buffer reference */
fb = gpu_get_frame_buffer();
sound_output_init(2 * 1024 * 1024, 44100);
return 1;
}
static uint32_t fb32[160 * 144];
typedef struct
{
uint32_t* vbuff;
@ -97,15 +86,17 @@ typedef struct
uint16_t keys; // keypad input
} frameinfo_t;
static uint32_t* current_vbuff;
EXPORT void FrameAdvance(frameinfo_t* frame)
{
input_set_keys(frame->keys);
uint64_t current = cycles.sampleclock;
current_vbuff = frame->vbuff;
gameboy_run(current + frame->clocks);
frame->clocks = cycles.sampleclock - current;
memcpy(frame->vbuff, fb32, 160 * 144 * sizeof(uint32_t));
frame->samples = sound_output_read(frame->sbuff);
current_vbuff = NULL;
}
EXPORT int IsCGB(void)
@ -113,20 +104,9 @@ EXPORT int IsCGB(void)
return global_cgb;
}
void cb()
void frame_cb()
{
// frame received into fb
uint16_t *src = fb;
uint8_t *dst = (uint8_t *)fb32;
for (int i = 0; i < 160 * 144; i++)
{
uint16_t c = *src++;
*dst++ = c << 3 & 0xf8 | c >> 2 & 7;
*dst++ = c >> 3 & 0xfa | c >> 9 & 3;
*dst++ = c >> 8 & 0xf8 | c >> 13 & 7;
*dst++ = 0xff;
}
memcpy(current_vbuff, gpu.frame_buffer, sizeof(gpu.frame_buffer));
}
void connected_cb()