Cleaned some comments and some readme

master
lerabot 4 years ago
parent 3eb5453e24
commit 06fd2d28ff
  1. 2
      02_drawing_using_GLdc/nehe02/Makefile
  2. 8
      02_drawing_using_GLdc/nehe02/README.md
  3. 56
      02_drawing_using_GLdc/nehe02/main.c
  4. BIN
      02_drawing_using_GLdc/nehe02/main.elf
  5. BIN
      02_drawing_using_GLdc/nehe02/romdisk.img
  6. 4
      02_drawing_using_GLdc/png_texture/Makefile
  7. 6
      02_drawing_using_GLdc/png_texture/README.md
  8. 10
      02_drawing_using_GLdc/png_texture/main.c
  9. BIN
      02_drawing_using_GLdc/png_texture/main.elf
  10. BIN
      02_drawing_using_GLdc/png_texture/romdisk.img
  11. 3
      03_controller_interaction/README.md
  12. 2
      03_controller_interaction/simple_control/Makefile
  13. 23
      03_controller_interaction/simple_control/README.md
  14. 3
      03_controller_interaction/simple_control/main.c
  15. BIN
      03_controller_interaction/simple_control/main.elf
  16. 3
      04_playing_sounds/README.md
  17. 12
      04_playing_sounds/multiple_sfx_player/main.c
  18. 2
      04_playing_sounds/ogg_player/Makefile
  19. 14
      04_playing_sounds/ogg_player/README.md
  20. 2
      04_playing_sounds/ogg_player/main.c
  21. BIN
      04_playing_sounds/ogg_player/main.elf
  22. BIN
      04_playing_sounds/ogg_player/romdisk.img
  23. 2
      04_playing_sounds/sfx_player/Makefile
  24. 11
      04_playing_sounds/sfx_player/README.md
  25. 7
      04_playing_sounds/sfx_player/main.c
  26. BIN
      04_playing_sounds/sfx_player/main.elf
  27. BIN
      04_playing_sounds/sfx_player/romdisk.img
  28. 9
      Makefile
  29. 14
      md_README.txt
  30. 14
      t.txt

@ -22,7 +22,7 @@ romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
lxdream $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img

@ -2,12 +2,10 @@
Everything is in the DrawGLScene function.
Please note the `glTranslateF` function which translate the whole scene at -6.0 in the z coordinate. A common error is to draw your scene at 0 z, which could be where your camera actually is, resulting in a black screen (or not just seeing your polygons)
Please note the `glTranslateF` function which translate the whole scene at -6.0 in the z coordinate. A common error is to draw your scene at 0.0 z, which could be where your camera actually is, resulting in a black screen (or not just seeing your polygons)
### Compile
### Makefile
Simply use `make`
### Run
`lxdream main.elf`
Run in lxdream using `make run`

@ -1,6 +1,13 @@
#include "gl.h"
#include "glu.h"
#include "glkos.h"
/******************************************************
Intro to GLdc using basic Quads/Triangle with glBegin() and glEnd()
Author: kazade
Date : 09/09/2018
*****************************************************/
#include <GL/gl.h>
#include <GL/glkos.h>
#include <GL/glu.h>
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
@ -19,22 +26,6 @@ void InitGL(int Width, int Height) // We call this right after our OpenG
glMatrixMode(GL_MODELVIEW);
}
/* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */
void ReSizeGLScene(int Width, int Height)
{
if (Height == 0) // Prevent A Divide By Zero If The Window Is Too Small
Height = 1;
glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
}
/* The main drawing function. */
void DrawGLScene()
{
@ -43,33 +34,36 @@ void DrawGLScene()
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
// draw a triangle
glBegin(GL_POLYGON); // start drawing a polygon
// Draw a triangle
glBegin(GL_POLYGON); // Start drawing a polygon
glColor3f( 1.0f, 1.0f, 1.0f); // Set the polygon color
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // we're done with the polygon
glEnd(); // Done with the polygon
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
// draw a square (quadrilateral)
glBegin(GL_QUADS); // start drawing a polygon (4 sided)
// Draw a quad (quadrilateral)
glBegin(GL_QUADS); // Start drawing a polygon (4 sided)
glColor3f( 0.0f, 1.0f, 0.0f); // Set the polygon color
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glColor3f( 0.0f, 1.0f, 1.0f); // Set the polygon color
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glColor3f( 0.5f, 0.0f, 0.7f); // Set the polygon color
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glColor3f( 0.0f, 0.4f, 0.9f); // Set the polygon color
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // done with the polygon
glEnd(); // Done with the polygon
// swap buffers to display, since we're double buffered.
// Swap buffers to display, since we're double buffered.
glKosSwapBuffers();
}
int main(int argc, char **argv)
{
glKosInit();
InitGL(640, 480);
ReSizeGLScene(640, 480);
glKosInit(); //Mandatory function to start KOS and set some GL params
InitGL(640, 480); //Create a "window" at the DC resolution
while(1) {
DrawGLScene();

@ -14,7 +14,7 @@ rm-elf:
$(TARGET): $(OBJS) romdisk.o
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) romdisk.o -lpng -lz -lGLdc -lm $(KOS_LIBS)
$(OBJS) romdisk.o -lpng -lz -lGLdc -lm $(KOS_LIBS)
romdisk.img:
$(KOS_GENROMFS) -f romdisk.img -d romdisk -v
@ -23,7 +23,7 @@ romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
lxdream $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img

@ -13,10 +13,8 @@ You can easily change `png_to_gl_texture` path and add your own image to the rom
Images need to be in pow2 (32x32, 64x64, 128x128, up to 1024x1024). You could technically go higher but not with the png color formats.
### Compile
### Makefile
Simply use `make`
### Run
`lxdream main.elf`
Run in lxdream using `make run`

@ -17,7 +17,8 @@ Date : 12/10/2018
extern uint8 romdisk[]; //Create a romsick pointer
KOS_INIT_ROMDISK(romdisk); //Init. the romdisk. Everything in the romdisk folder is now located at /rd/ on your DC.
texture t1;
texture t1; //This will hold at the data for our texture. Located in gl_png.h
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
@ -29,19 +30,20 @@ void InitGL(int Width, int Height) // We call this right after our OpenG
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
}
int main() {
maple_device_t *cont; //controller
cont_state_t *state; //state of inputs
maple_device_t *cont; //Controller
cont_state_t *state; //State of inputs
glKosInit(); //Mandatory function to start KOS and set some GL params
InitGL(640, 480); //Create a "window" at the DC resolution
//This function is in gl_png.c
png_to_gl_texture(&t1, "/rd/controller.png"); //This function will load a PNG file into a texture <-------------------
float angle = 0.0f;

@ -1,4 +1 @@
# Dreamcast Tutorials
For anyone who wants to learn the basic of Dreamcast programming.
Make sure you check the [wiki](https://github.com/dreamcastdevs/dreamcast_tutorial/wiki) for more info.

@ -23,7 +23,7 @@ romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
lxdream $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img

@ -0,0 +1,23 @@
### What to look for
Here, we're using the Dreamcast controller to interact with the scene.
Keep an eye open for the `maple_device_t` and `cont_state_t`. The maple device keep track of that's plugged in (VMU, keyboard, etc) while the states keep tracks of it's buttons and joystick.
You'll need to call `(cont_state_t *)maple_dev_status(cont)` if you want to pool data on each frame.
Here's the [KOS reference](http://gamedev.allusion.net/docs/kos-2.0.0/structcont__state__t.html) if you need to know what the `state` holds.
Using the D-PAD is simple. You usually want people to hold it to move around. Using something like `if(state->buttons & CONT_DPAD_UP)` will usually do the trick.
The joystick are also quite simple. `state->joyx` will return a number between -127 and +127.
Button A will change the color of the square. Since we need a single button press, you'll need to check the difference between the previous inputs and the current one. There are many way to do this.
There's a simple function called `buttonPress(cont_state_t *state, int key)` which will take a "state" and a button key code which will check if but button is newly pressed. For this to work, you need `p_buttons &= state->buttons;` at the end of your code. This will keep track of the newly pressed buttons.
### Makefile
Simply use `make`
Run in lxdream using `make run`

@ -1,6 +1,5 @@
/******************************************************
This is a simple exemple to learn
how to use the controller inputs.
This is a simple exemple to learn how to use the controller inputs.
This uses Kazade's GLdc and some part of his NeHe example.

@ -1,4 +1 @@
# Dreamcast Tutorials
For anyone who wants to learn the basic of Dreamcast programming.
Make sure you check the [wiki](https://github.com/dreamcastdevs/dreamcast_tutorial/wiki) for more info.

@ -8,7 +8,7 @@ Date : 09/09/2018
#include <stdio.h>
#include <stdlib.h>
extern uint8 romdisk[]; //Create a romsick pointer
extern uint8 romdisk[]; //Create a romdisk pointer
KOS_INIT_ROMDISK (romdisk); //Init. the romdisk. Everything in the romdisk folder is now located at /rd/ on your DC.
uint32_t p_buttons; //Saves the previous button states
@ -22,17 +22,17 @@ int buttonPressed(cont_state_t *state, uint16 key) {
}
int main() {
maple_device_t *cont; //controller
cont_state_t *state; //state of inputs
maple_device_t *cont; //Controller
cont_state_t *state; //State of inputs
while(1) {
// Refresh the controller data
//Refresh the controller data
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
// Check key status
//Check key status
state = (cont_state_t *)maple_dev_status(cont);
// If the state/controller is unavailable
//If the state/controller is unavailable
if(!state) {
printf("Error reading controller\n");
break;

@ -23,7 +23,7 @@ romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
lxdream $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img

@ -0,0 +1,14 @@
### What to look for
This is a very barebone .ogg player witgh simple controls.
DPAD will increase/decrese volume and A/B will start/stop.
The snd libraries (ogg/mp3) will stream mono/stereotrack. When I say stream, I mean that will handle filling the sound buffer with your audio file and playing it in a seemless way. It's very useful for background music if you want to store your sound on `/cd`
(Note that if you use the mp3 library you might need to make your project open source due to legal stuff of the library that the mp3 port depends on)
### Makefile
Simply use `make`
Run in lxdream using `make run`

@ -64,6 +64,6 @@ int main() {
p_buttons &= state->buttons; //This operation will set p_buttons as the latest changes in states.
}
sndoggvorbis_shutdown()
sndoggvorbis_shutdown();
return(0);
}

@ -23,7 +23,7 @@ romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
lxdream $(TARGET)
dist:
rm -f $(OBJS) romdisk.o romdisk.img

@ -1,6 +1,13 @@
# Basic sound effect example
### What to look for
This program exists to give you an idea of how to use the snd_sfx\* stuff. **Note that this not for playing background music** look at KOS' ogg, cdda, etc examples which use streaming techniques (Note that if you use the mp3 library you might need to make your project open source due to legal stuff of the library that the mp3 port depends on)
This program exists to give you an idea of how to use the snd_sfx\* stuff. **Note that this not for playing background music** look at KOS' ogg, cdda, etc examples which use streaming techniques
(Note that if you use the mp3 library you might need to make your project open source due to legal stuff of the library that the mp3 port depends on)
The audio file included is the metallic sound from when Sonic Adventure 2 is loading a level (Its specifically from a Sonic Heroes Prototype)
### Makefile
Simply use `make`
Run in lxdream using `make run`

@ -6,9 +6,8 @@ made by Protofall with some minor changes by lerabot.
#include <kos.h>
#include <stdint.h>
// Romdisk
extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
extern uint8 romdisk[]; //Create a romdisk pointer
KOS_INIT_ROMDISK (romdisk); //Init. the romdisk. Everything in the romdisk folder is now located at /rd/ on your DC.
//Check if check_button was just released (Unused)
uint8_t button_released(cont_state_t *st, uint32_t check_button, uint32_t changed_buttons){
@ -55,7 +54,7 @@ int main(){
changed_buttons = current_state->buttons ^ previous_buttons;
if(current_state != NULL && button_pressed(current_state, CONT_A, changed_buttons)){ //When the "A" button is pressed, play the sound
snd_sfx_play(sound1, 127, 128); // ~50% volume, pan centred
snd_sfx_play(sound1, 127, 128); //~50% volume, pan centred
}
previous_buttons = current_state->buttons;

@ -0,0 +1,9 @@
DIRS = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
wiki:
for i in $(DIRS) ; do \
cd $(i) ; \
ifeq (,$(wildcard ./README.md)) ; \
pandoc -f markdown -t mediawiki README.md > md_README.txt ; \
endif ; \
done

@ -0,0 +1,14 @@
= Dreamcast Tutorials =
For anyone who wants to learn the basic of Dreamcast programming.
This is an attempt to solidify on [http://dcemulation.org/?title=Development DCemulation Wiki] section. Make sure you check the [https://github.com/dreamcastdevs/dreamcast_tutorial/wiki wiki] for more info.
=== Issues ===
Please report the issues if you find some.
=== Contact ===
I'm reachable on Discord @ magnes#3788, there are also some DC Dev channel on discord, feel free to ask me over there.

14
t.txt

@ -0,0 +1,14 @@
= Dreamcast Tutorials =
For anyone who wants to learn the basic of Dreamcast programming.
This is an attempt to solidify on [http://dcemulation.org/?title=Development DCemulation Wiki] section. Make sure you check the [https://github.com/dreamcastdevs/dreamcast_tutorial/wiki wiki] for more info.
=== Issues ===
Please report the issues if you find some.
=== Contact ===
I'm reachable on Discord @ magnes#3788, there are also some DC Dev channel on discord, feel free to ask me over there.
Loading…
Cancel
Save