Updated the makefile, controller pooling, and Readme

master
lerabot 4 years ago
parent 5b080d76fc
commit 49419ae832
  1. 2
      .gitignore
  2. 38
      Makefile
  3. 30
      Makefile.KOS
  4. 51
      README
  5. 34
      dreamroq-player.c
  6. 1764
      dreamroqlib.c
  7. 162
      dreamroqlib.h

2
.gitignore vendored

@ -2,3 +2,5 @@
test-dreamroq
*.pnm
roq-audio.wav
*.iso
*.gch

@ -1,8 +1,38 @@
all: test-dreamroq
# Put the filename of the output binary here
TARGET = dreamroq-player.elf
DIR=$(PWD)
CFLAGS += -Wall
# List all of your C files here, but change the extension to ".o"
OBJS = dreamroq-player.o dreamroqlib.o
test-dreamroq: test-dreamroq.o dreamroqlib.o
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean:
rm -f *.o test-dreamroq
-rm -f $(TARGET) $(OBJS)
rm-elf:
-rm -f $(TARGET)
# If you don't need a ROMDISK, then remove "romdisk.o" from the next few
# lines. Also change the -l arguments to include everything you need,
# such as -lmp3, etc.. these will need to go _before_ $(KOS_LIBS)
$(TARGET): $(OBJS)
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) $(OBJEXTRA) $(KOS_LIBS)
cd: $(TARGET) $(OBJS)
#elf transform ---- make sure the *.elf name matches your .elf file.
sh-elf-objcopy -R .stack -O binary $(TARGET) output.bin
#scraming process
$(KOS_BASE)/utils/scramble/scramble output.bin 1ST_READ.bin
#creating iso -> -o outputname.iso
mkisofs -C 0,11702 -V DC_GAME -G IP.BIN -r -J -l -m '*.o' -x $(DIR)/builds -o $(DIR)/builds/$(TARGET).iso $(DIR)
run: $(CD)
lxdream builds/$(TARGET).iso
dist:
rm -f $(OBJS) romdisk.o romdisk.img
$(KOS_STRIP) $(TARGET)

@ -1,30 +0,0 @@
# Put the filename of the output binary here
TARGET = dreamroq-player.elf
# List all of your C files here, but change the extension to ".o"
OBJS = dreamroq-player.o dreamroqlib.o
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean:
-rm -f $(TARGET) $(OBJS)
rm-elf:
-rm -f $(TARGET)
# If you don't need a ROMDISK, then remove "romdisk.o" from the next few
# lines. Also change the -l arguments to include everything you need,
# such as -lmp3, etc.. these will need to go _before_ $(KOS_LIBS)
$(TARGET): $(OBJS)
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) $(OBJEXTRA) $(KOS_LIBS)
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img
$(KOS_STRIP) $(TARGET)

@ -1,7 +1,9 @@
Dreamroq Library
# Dreamroq Library
_This is a fork of the original project, we're currently trying to have the video play at the desired framerate._
### Introduction
Introduction
============
Dreamroq is a RoQ playback library designed for the Sega Dreamcast video
game console.
@ -28,43 +30,22 @@ RoQ files can also be created using the Switchblade encoder:
http://icculus.org/~riot/
A version of Switchblade is also included in FFmpeg and many derivative
programs:
Or by using FFmpeg:
`ffmpeg -i input_video.mp4 -o output_video.roq`
http://ffmpeg.org/
License
=======
### License
Dreamroq is meant to be license-compatible with the rest of the KallistiOS
operating system, which is a BSD-style open source license. You can read
the specific text in LICENSE.KOS.
Building (Unix)
===============
To build and test on Linux/Mac OS X/Cygwin, simply type:
make
in the source directory. This will build the executable test-dreamroq. This
utility has the following usage:
./test-dreamroq <file.roq>
### Building (KOS)
This will decode the RoQ file from the command line into a series of PNM
files in the current working directory (watch out-- this could take up a
lot of disk space).
Building (KOS)
==============
There are 2 Makefiles included with Dreamroq. The first -- implicitly
invoked when running a bare 'make' command as seen in the "Building (Unix)"
section -- builds the test utility. The second Makefile is Makefile.KOS,
invoked with:
make -f Makefile.KOS
`make`
This is a standard KOS Makefile which assumes that a KOS build environment
is available. This is covered in the KOS documentation. This step will
@ -78,8 +59,8 @@ ELF file (which is well supported in KOS) and load the file from the '/rd'
mount point.
Bugs, Issues, and Future Development
====================================
### Bugs, Issues, and Future Development
The player is just a proof of concept at this point. It doesn't try to
render frames with proper timing-- it just plays them as fast as possible
(which often isn't very fast, mostly due to the I/O bottleneck).
@ -92,8 +73,10 @@ Currently, the first call to the render callback initializes the PVR buffers
but they are never explicitly freed.
Credits
=======
### Credits
Library originally written by Mike Melanson (mike -at- multimedia.cx)
Audio support added by Josh "PH3NOM" Pearson ([email protected])
Audio and framerate fix by MrNeo240 and lerabot

@ -5,7 +5,7 @@
* the KallistiOS operating system.
*/
#include "kos.h"
#include <kos.h>
#include "dreamroqlib.h"
@ -52,11 +52,11 @@ static int render_cb(void *buf_ptr, int width, int height, int stride,
br_y = ul_y + ratio * texture_height;
/* Things common to vertices */
vert[0].z = vert[1].z = vert[2].z = vert[3].z = 1.0f;
vert[0].argb = vert[1].argb = vert[2].argb = vert[3].argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
vert[0].oargb = vert[1].oargb = vert[2].oargb = vert[3].oargb = 0;
vert[0].flags = vert[1].flags = vert[2].flags = PVR_CMD_VERTEX;
vert[3].flags = PVR_CMD_VERTEX_EOL;
vert[0].z = vert[1].z = vert[2].z = vert[3].z = 1.0f;
vert[0].argb = vert[1].argb = vert[2].argb = vert[3].argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
vert[0].oargb = vert[1].oargb = vert[2].oargb = vert[3].oargb = 0;
vert[0].flags = vert[1].flags = vert[2].flags = PVR_CMD_VERTEX;
vert[3].flags = PVR_CMD_VERTEX_EOL;
vert[0].x = ul_x;
vert[0].y = ul_y;
@ -112,16 +112,19 @@ int audio_cb(unsigned char *buf_rgb565, int samples, int channels)
static int quit_cb()
{
cont_cond_t cont;
maple_device_t *cont; //Controller
cont_state_t *state; //State of inputs
/* check controller state */
if (cont_get_cond(maple_first_controller(), &cont))
{
/* controller read error */
return 1;
state = maple_dev_status(cont);
// If the state/controller is unavailable
if(!state) {
printf("Error reading controller\n");
return(0);
}
cont.buttons = ~cont.buttons;
return (cont.buttons & CONT_START);
state->buttons = ~state->buttons;
return (state->buttons & CONT_START);
}
int finish_cb()
@ -142,9 +145,8 @@ int main()
vid_set_mode(DM_640x480_NTSC_IL, PM_RGB565);
pvr_init_defaults();
status = dreamroq_play("/cd/venuscubes.roq", ROQ_RGB565, 1, &cbs);
status = dreamroq_play("/cd/cube_v1.roq", ROQ_RGB565, 1, &cbs);
printf("dreamroq_play() status = %d\n", status);
return 0;
}

File diff suppressed because it is too large Load Diff

@ -1,52 +1,110 @@
/*
* Dreamroq by Mike Melanson
*
* This is the header file to be included in the programs wishing to
* use the Dreamroq playback engine.
*/
#ifndef NEWROQ_H
#define NEWROQ_H
#define ROQ_SUCCESS 0
#define ROQ_FILE_OPEN_FAILURE 1
#define ROQ_FILE_READ_FAILURE 2
#define ROQ_CHUNK_TOO_LARGE 3
#define ROQ_BAD_CODEBOOK 4
#define ROQ_INVALID_PIC_SIZE 5
#define ROQ_NO_MEMORY 6
#define ROQ_BAD_VQ_STREAM 7
#define ROQ_INVALID_DIMENSION 8
#define ROQ_RENDER_PROBLEM 9
#define ROQ_CLIENT_PROBLEM 10
#define ROQ_RGB565 0
#define ROQ_RGBA 1
/* The library calls this function when it has a frame ready for display. */
typedef int (*render_callback)(void *buf, int width, int height,
int stride, int texture_height, int colorspace);
/* The library calls this function when it has pcm samples ready for output. */
typedef int (*audio_callback)(unsigned char *buf, int samples, int channels);
/* The library calls this function to ask whether it should quit playback.
* Return non-zero if it's time to quit. */
typedef int (*quit_callback)();
/* The library calls this function to indicate that playback of the movie is
* complete. */
typedef int (*finish_callback)(void);
typedef struct
{
render_callback render_cb;
audio_callback audio_cb;
quit_callback quit_cb;
finish_callback finish_cb;
} roq_callbacks_t;
int dreamroq_play(char *filename, int colorspace, int loop,
roq_callbacks_t *callbacks);
#endif /* NEWROQ_H */
/*
* Dreamroq by Mike Melanson
*
* This is the header file to be included in the programs wishing to
* use the Dreamroq playback engine.
*/
#pragma once
#ifndef NEWROQ_H
#define NEWROQ_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ROQ_SUCCESS 0
#define ROQ_FILE_OPEN_FAILURE 1
#define ROQ_FILE_READ_FAILURE 2
#define ROQ_CHUNK_TOO_LARGE 3
#define ROQ_BAD_CODEBOOK 4
#define ROQ_INVALID_PIC_SIZE 5
#define ROQ_NO_MEMORY 6
#define ROQ_BAD_VQ_STREAM 7
#define ROQ_INVALID_DIMENSION 8
#define ROQ_RENDER_PROBLEM 9
#define ROQ_CLIENT_PROBLEM 10
#define ROQ_RGB565 0
#define ROQ_RGBA 1
#define RoQ_INFO 0x1001
#define RoQ_QUAD_CODEBOOK 0x1002
#define RoQ_QUAD_VQ 0x1011
#define RoQ_JPEG 0x1012
#define RoQ_SOUND_MONO 0x1020
#define RoQ_SOUND_STEREO 0x1021
#define RoQ_PACKET 0x1030
#define RoQ_SIGNATURE 0x1084
#define CHUNK_HEADER_SIZE 8
#define LE_16(buf) (*buf | (*(buf+1) << 8))
#define LE_32(buf) (*buf | (*(buf+1) << 8) | (*(buf+2) << 16) | (*(buf+3) << 24))
#define MAX_BUF_SIZE (64 * 1024)
#define ROQ_CODEBOOK_SIZE 256
#define SQR_ARRAY_SIZE 256
typedef struct
{
int pcm_samples;
int channels;
int position;
short snd_sqr_array[SQR_ARRAY_SIZE];
unsigned char pcm_sample[MAX_BUF_SIZE];
} roq_audio;
typedef struct
{
int width;
int height;
int mb_width;
int mb_height;
int mb_count;
int alpha;
int current_frame;
unsigned char *frame[2];
int stride;
int texture_height;
int colorspace;
unsigned short cb2x2_rgb565[ROQ_CODEBOOK_SIZE][4];
unsigned short cb4x4_rgb565[ROQ_CODEBOOK_SIZE][16];
unsigned int cb2x2_rgba[ROQ_CODEBOOK_SIZE][4];
unsigned int cb4x4_rgba[ROQ_CODEBOOK_SIZE][16];
} roq_state;
/* The library calls this function when it has a frame ready for display. */
typedef int (*render_callback)(void *buf, int width, int height,
int stride, int texture_height, int colorspace);
/* The library calls this function when it has pcm samples ready for output. */
typedef int (*audio_callback)(unsigned char *buf, int samples, int channels);
/* The library calls this function to ask whether it should quit playback.
* Return non-zero if it's time to quit. */
typedef int (*quit_callback)();
/* The library calls this function to indicate that playback of the movie is
* complete. */
typedef int (*finish_callback)(void);
typedef struct
{
render_callback render_cb;
audio_callback audio_cb;
quit_callback quit_cb;
finish_callback finish_cb;
} roq_callbacks_t;
int dreamroq_play(char *filename, int colorspace, int loop, roq_callbacks_t *callbacks);
int roq_unpack_quad_codebook_rgb565(unsigned char *buf, int size, int arg, roq_state *state);
int roq_unpack_quad_codebook_rgba(unsigned char *buf, int size, int arg, roq_state *state);
int roq_unpack_vq_rgb565(unsigned char *buf, int size, unsigned int arg, roq_state *state);
int roq_unpack_vq_rgba(unsigned char *buf, int size, unsigned int arg, roq_state *state);
#endif /* NEWROQ_H */

Loading…
Cancel
Save