├── .gitignore
├── InstallDreamcast.md
├── LICENSE
├── README.md
├── dreamcastbuild.sh
└── samples
├── models
└── cubicmap
│ ├── Makefile
│ ├── main.c
│ └── romdisk
│ ├── cubicmap.png
│ └── cubicmap_atlas.png
└── shapes
├── basic_shapes
├── Makefile
├── main.c
└── romdisk
│ └── empty
├── collision_area
├── Makefile
├── main.c
└── romdisk
│ └── empty
└── logo_raylib_anim
├── Makefile
├── main.c
└── romdisk
└── empty
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
54 | #mac
55 | .DS_Store
56 | ._*
57 |
--------------------------------------------------------------------------------
/InstallDreamcast.md:
--------------------------------------------------------------------------------
1 | # Install for Dreamcast
2 | - Install last kos and kos-port follow steps from https://dreamcast.wiki/Getting_Started_with_Dreamcast_development
3 | - clone this repository and execute if you are in Unix like environtment including wsl2:
4 | ```
5 | ./dreamcastbuild.sh
6 | ```
7 |
8 | # Samples
9 | - in each sample use make to build
10 | ```
11 | % cd samples
12 | % ls
13 | models shapes
14 | % cd models
15 | % ls
16 | cubicmap
17 | % cd cubicmap
18 | % ls
19 | Makefile main.c romdisk
20 | % make
21 | rm -f raylib.elf romdisk.*
22 | kos-cc -c main.c -o main.o
23 | /usr/local/dcdev/kos/utils/genromfs/genromfs -f romdisk.img -d romdisk -v -x .svn -x .keepme
24 | 0 rom 1706461643 [0xffffffff, 0xffffffff] 37777777777, sz 0, at 0x0
25 | 1 . [0x820 , 0x5c9 ] 0040755, sz 0, at 0x20
26 | 1 .. [0x820 , 0x5951b ] 0040755, sz 0, at 0x40 [link to 0x20 ]
27 | 1 cubicmap_atlas.png [0x820 , 0x59520 ] 0100644, sz 37160, at 0x60
28 | 1 cubicmap.png [0x820 , 0x5951f ] 0100644, sz 164, at 0x91c0
29 | /usr/local/dcdev/kos/utils/bin2o/bin2o romdisk.img romdisk romdisk_tmp.o
30 | /usr/local/dcdev/sh-elf/bin/sh-elf-gcc -o romdisk.o -r romdisk_tmp.o -L/usr/local/dcdev/kos/lib/dreamcast -L/usr/local/dcdev/kos/addons/lib/dreamcast -L/usr/local/dcdev/kos/../kos-ports/lib -Wl,--whole-archive -lromdiskbase
31 | rm romdisk_tmp.o
32 | kos-cc -o raylib.elf main.o romdisk.o -lraylib -lGL -lm -lkosutils
33 | ```
34 | - If you have a broadband adapter make it happy using
35 | ```
36 | % dc-tool-ip -t HEREYOURDREAMCASTIP -x raylib.elf
37 | ```
38 |
39 | Enjoy!!!!
40 |
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013-2023 Ramon Santamaria (@raysan5)
2 |
3 | This software is provided "as-is", without any express or implied warranty. In no event
4 | will the authors be held liable for any damages arising from the use of this software.
5 |
6 | Permission is granted to anyone to use this software for any purpose, including commercial
7 | applications, and to alter it and redistribute it freely, subject to the following restrictions:
8 |
9 | 1. The origin of this software must not be misrepresented; you must not claim that you
10 | wrote the original software. If you use this software in a product, an acknowledgment
11 | in the product documentation would be appreciated but is not required.
12 |
13 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented
14 | as being the original software.
15 |
16 | 3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # raylib4Dreamcast
2 | raylib4Dreamcast is a raylib port for Sega Dreamcast [new home ](https://github.com/raylib4Consoles/raylib4Dreamcast)
3 |
4 | [](https://ko-fi.com/S6S6TSF2C)
5 |
6 |
7 |
8 | **raylib is a simple and easy-to-use library to enjoy videogames programming.**
9 |
10 | raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
11 |
12 | *NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
13 |
14 | Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
15 |
16 | ---
17 |
18 | Change log
19 | ===========================
20 | - 28/1/2024 Initial raylib4Dreamcast public release
21 |
22 |
23 | Credits
24 | ===========================
25 |
26 | - @raysan5 for his amazing work with raylib and raylib has an incredible community developing in the open way!!!!
27 | - @falco_girgis guilty by call my attention about cool things done with Sega Dreamcast
28 | - all people involved in homebrew tools and libraries for Dreamcast.
29 |
30 |
31 | License
32 | ===========================
33 |
34 | raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
35 |
--------------------------------------------------------------------------------
/dreamcastbuild.sh:
--------------------------------------------------------------------------------
1 |
2 | ## Check if $KOS_BASE is set.
3 | if test ! $KOS_BASE; then { echo "ERROR: Set \$KOS_BASE installing kos sdk and kos-ports before continuing."; exit 1; } fi
4 |
5 | ## Check if KOS_PORTS is set.
6 | if test ! $KOS_PORTS; then { echo "ERROR: Set \$KOS_PORTS installing kos sdk and kos-ports before continuing."; exit 1; } fi
7 |
8 | git clone https://github.com/raylib4Consoles/raylib -b dreamcast
9 | cd raylib/src
10 | make
11 | make install
12 |
--------------------------------------------------------------------------------
/samples/models/cubicmap/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # KallistiGL test program
3 | # (c)2013-2014 Josh PH3NOM Pearson
4 | # (c)2001 Megan Potter
5 | #
6 |
7 | TARGET = raylib.elf
8 | OBJS = main.o romdisk.o
9 | KOS_ROMDISK_DIR = romdisk
10 |
11 | all: rm-elf $(TARGET)
12 |
13 | include $(KOS_BASE)/Makefile.rules
14 |
15 | clean: rm-elf
16 | -rm -f $(OBJS)
17 |
18 | rm-elf:
19 | -rm -f $(TARGET) romdisk.*
20 |
21 | $(TARGET): $(OBJS)
22 | kos-cc -o $(TARGET) $(OBJS) -lraylib -lGL -lm -lkosutils
23 |
24 | run: $(TARGET)
25 | $(KOS_LOADER) $(TARGET)
26 |
27 | dist: $(TARGET)
28 | -rm -f $(OBJS) romdisk.img
29 | $(KOS_STRIP) $(TARGET)
30 |
31 |
--------------------------------------------------------------------------------
/samples/models/cubicmap/main.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * raylib [models] example - Cubicmap loading and drawing
4 | *
5 | * Example originally created with raylib 1.8, last time updated with raylib 3.5
6 | *
7 | * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
8 | * BSD-like license that allows static linking with closed source software
9 | *
10 | * Copyright (c) 2015-2024 Ramon Santamaria (@raysan5)
11 | *
12 | ********************************************************************************************/
13 |
14 |
15 | #include
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 |
22 | #define ATTR_ORBIS_WIDTH 640
23 | #define ATTR_ORBIS_HEIGHT 480
24 | bool flag=true;
25 | bool xflag=false;
26 | maple_device_t *cont;
27 | cont_state_t *pad_state;
28 |
29 |
30 | void updateController()
31 | {
32 | cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
33 |
34 | if(cont)
35 | {
36 | pad_state = (cont_state_t *)maple_dev_status(cont);
37 |
38 | if(!pad_state)
39 | {
40 | printf("Error reading controller\n");
41 | }
42 |
43 | if(pad_state->buttons & CONT_START)
44 | {
45 | flag=0;
46 | }
47 | if(pad_state->buttons & CONT_A)
48 | {
49 | xflag = !xflag;
50 | }
51 | }
52 | }
53 |
54 | bool initApp()
55 | {
56 | return true;
57 | }
58 | void finishApp()
59 | {
60 |
61 |
62 | }
63 | //------------------------------------------------------------------------------------
64 | // Program main entry point
65 | //------------------------------------------------------------------------------------
66 | int main(void)
67 | {
68 | // Initialization
69 | //--------------------------------------------------------------------------------------
70 | const int screenWidth = ATTR_ORBIS_WIDTH;
71 | const int screenHeight = ATTR_ORBIS_HEIGHT;
72 |
73 | InitWindow(screenWidth, screenHeight, "raylib [models] example - cubicmap");
74 |
75 | // Define the camera to look into our 3d world
76 | Camera camera = { 0 };
77 | camera.position = (Vector3){ 16.0f, 14.0f, 16.0f }; // Camera position
78 | camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
79 | camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
80 | camera.fovy = 45.0f; // Camera field-of-view Y
81 | camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
82 |
83 | Image image = LoadImage("/rd/cubicmap.png"); // Load cubicmap image (RAM)
84 | Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
85 |
86 | Mesh mesh = GenMeshCubicmap(image, (Vector3){ 1.0f, 1.0f, 1.0f });
87 | Model model = LoadModelFromMesh(mesh);
88 |
89 | // NOTE: By default each cube is mapped to one part of texture atlas
90 | Texture2D texture = LoadTexture("/rd/cubicmap_atlas.png"); // Load map texture
91 | model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
92 |
93 | Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
94 |
95 | UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
96 |
97 |
98 |
99 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second
100 | //----------------------------------------------------------
101 |
102 | // Main game loop
103 | while (flag) // Detect window close button or ESC key
104 | {
105 | // Update
106 | //-----------------------------------------------------
107 | updateController();
108 |
109 | // Update
110 | //----------------------------------------------------------------------------------
111 | UpdateCamera(&camera, CAMERA_ORBITAL);
112 | //----------------------------------------------------------------------------------
113 |
114 | // Draw
115 | //----------------------------------------------------------------------------------
116 | BeginDrawing();
117 |
118 | ClearBackground(RAYWHITE);
119 |
120 | BeginMode3D(camera);
121 |
122 | DrawModel(model, mapPosition, 1.0f, WHITE);
123 |
124 | EndMode3D();
125 |
126 | DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4.0f - 20, 20.0f }, 0.0f, 4.0f, WHITE);
127 | DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
128 |
129 | DrawText("cubicmap image used to", 658, 90, 10, GRAY);
130 | DrawText("generate map 3d model", 658, 104, 10, GRAY);
131 |
132 | DrawFPS(10, 10);
133 |
134 | EndDrawing();
135 |
136 |
137 | //-----------------------------------------------------
138 | }
139 |
140 | // De-Initialization
141 | //--------------------------------------------------------------------------------------
142 | UnloadTexture(cubicmap); // Unload cubicmap texture
143 | UnloadTexture(texture); // Unload map texture
144 | UnloadModel(model); // Unload map model
145 |
146 | CloseWindow(); // Close window and OpenGL context
147 | //----------------------------------------------------------
148 |
149 | finishApp();
150 | return 0;
151 | }
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/samples/models/cubicmap/romdisk/cubicmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/psxdev/raylib4Dreamcast/14f4d94cd9988c180c0ece64647d14e3515c1191/samples/models/cubicmap/romdisk/cubicmap.png
--------------------------------------------------------------------------------
/samples/models/cubicmap/romdisk/cubicmap_atlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/psxdev/raylib4Dreamcast/14f4d94cd9988c180c0ece64647d14e3515c1191/samples/models/cubicmap/romdisk/cubicmap_atlas.png
--------------------------------------------------------------------------------
/samples/shapes/basic_shapes/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # KallistiGL test program
3 | # (c)2013-2014 Josh PH3NOM Pearson
4 | # (c)2001 Megan Potter
5 | #
6 |
7 | TARGET = raylib.elf
8 | OBJS = main.o romdisk.o
9 | KOS_ROMDISK_DIR = romdisk
10 |
11 | all: rm-elf $(TARGET)
12 |
13 | include $(KOS_BASE)/Makefile.rules
14 |
15 | clean: rm-elf
16 | -rm -f $(OBJS)
17 |
18 | rm-elf:
19 | -rm -f $(TARGET) romdisk.*
20 |
21 | $(TARGET): $(OBJS)
22 | kos-cc -o $(TARGET) $(OBJS) -lraylib -lGL -lm -lkosutils
23 |
24 | run: $(TARGET)
25 | $(KOS_LOADER) $(TARGET)
26 |
27 | dist: $(TARGET)
28 | -rm -f $(OBJS) romdisk.img
29 | $(KOS_STRIP) $(TARGET)
30 |
31 |
--------------------------------------------------------------------------------
/samples/shapes/basic_shapes/main.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
4 | *
5 | * Example originally created with raylib 1.0, last time updated with raylib 4.2
6 | *
7 | * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
8 | * BSD-like license that allows static linking with closed source software
9 | *
10 | * Copyright (c) 2014-2024 Ramon Santamaria (@raysan5)
11 | *
12 | ********************************************************************************************/
13 |
14 | #include
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define ATTR_DREAMCAST_WIDTH 640
22 | #define ATTR_DREAMCAST_HEIGHT 480
23 | bool flag=true;
24 | bool xflag=false;
25 | maple_device_t *cont;
26 | cont_state_t *pad_state;
27 |
28 |
29 | void updateController()
30 | {
31 | cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
32 |
33 | if(cont)
34 | {
35 | pad_state = (cont_state_t *)maple_dev_status(cont);
36 |
37 | if(!pad_state)
38 | {
39 | printf("Error reading controller\n");
40 | }
41 |
42 | if(pad_state->buttons & CONT_START)
43 | {
44 | flag=0;
45 | }
46 | if(pad_state->buttons & CONT_A)
47 | {
48 | xflag = !xflag;
49 | }
50 | }
51 | }
52 |
53 | bool initApp()
54 | {
55 | return true;
56 | }
57 | void finishApp()
58 | {
59 |
60 |
61 | }
62 | //------------------------------------------------------------------------------------
63 | // Program main entry point
64 | //------------------------------------------------------------------------------------
65 | int main(void)
66 | {
67 | // Initialization
68 | //--------------------------------------------------------------------------------------
69 | const int screenWidth = ATTR_DREAMCAST_WIDTH;
70 | const int screenHeight = ATTR_DREAMCAST_HEIGHT;
71 |
72 | InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes");
73 |
74 | float rotation = 0.0f;
75 |
76 |
77 |
78 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second
79 | //----------------------------------------------------------
80 |
81 | // Main game loop
82 | while (flag) // Detect window close with Start button
83 | {
84 | // Update
85 | //-----------------------------------------------------
86 | updateController();
87 |
88 | //----------------------------------------------------------------------------------
89 | rotation += 0.2f;
90 | //----------------------------------------------------------------------------------
91 |
92 | // Draw
93 | //----------------------------------------------------------------------------------
94 | BeginDrawing();
95 |
96 | ClearBackground(RAYWHITE);
97 |
98 | DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
99 |
100 | // Circle shapes and lines
101 | DrawCircle(screenWidth/5, 120, 35, DARKBLUE);
102 | DrawCircleGradient(screenWidth/5, 220, 60, GREEN, SKYBLUE);
103 | DrawCircleLines(screenWidth/5, 340, 80, DARKBLUE); //not supported on Dreamcast
104 |
105 | // Rectangle shapes and lines
106 | DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
107 | DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
108 | DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
109 |
110 | // Triangle shapes and lines
111 | DrawTriangle((Vector2){ screenWidth/4.0f *3.0f, 80.0f },
112 | (Vector2){ screenWidth/4.0f *3.0f - 60.0f, 150.0f },
113 | (Vector2){ screenWidth/4.0f *3.0f + 60.0f, 150.0f }, VIOLET);
114 |
115 | DrawTriangleLines((Vector2){ screenWidth/4.0f*3.0f, 160.0f },
116 | (Vector2){ screenWidth/4.0f*3.0f - 20.0f, 230.0f },
117 | (Vector2){ screenWidth/4.0f*3.0f + 20.0f, 230.0f }, DARKBLUE);//Not supported on Dreamcast
118 |
119 | // Polygon shapes and lines
120 | DrawPoly((Vector2){ screenWidth/4.0f*3, 330 }, 6, 80, rotation, BROWN);
121 | DrawPolyLines((Vector2){ screenWidth/4.0f*3, 330 }, 6, 90, rotation, BROWN); //Not supported on Dreamcast
122 | DrawPolyLinesEx((Vector2){ screenWidth/4.0f*3, 330 }, 6, 85, rotation, 6, BEIGE);
123 |
124 | // NOTE: We draw all LINES based shapes together to optimize internal drawing,
125 | // this way, all LINES are rendered in a single draw pass
126 | //DrawLine(18, 42, screenWidth - 18, 42, BLACK); //not supported on Dreamcast
127 | EndDrawing();
128 |
129 |
130 | //-----------------------------------------------------
131 | }
132 |
133 | // De-Initialization
134 | //---------------------------------------------------------
135 | CloseWindow(); // Close window and OpenGL context
136 | //----------------------------------------------------------
137 |
138 | finishApp();
139 | return 0;
140 | }
141 |
--------------------------------------------------------------------------------
/samples/shapes/basic_shapes/romdisk/empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/psxdev/raylib4Dreamcast/14f4d94cd9988c180c0ece64647d14e3515c1191/samples/shapes/basic_shapes/romdisk/empty
--------------------------------------------------------------------------------
/samples/shapes/collision_area/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # KallistiGL test program
3 | # (c)2013-2014 Josh PH3NOM Pearson
4 | # (c)2001 Megan Potter
5 | #
6 |
7 | TARGET = raylib.elf
8 | OBJS = main.o romdisk.o
9 | KOS_ROMDISK_DIR = romdisk
10 |
11 | all: rm-elf $(TARGET)
12 |
13 | include $(KOS_BASE)/Makefile.rules
14 |
15 | clean: rm-elf
16 | -rm -f $(OBJS)
17 |
18 | rm-elf:
19 | -rm -f $(TARGET) romdisk.*
20 |
21 | $(TARGET): $(OBJS)
22 | kos-cc -o $(TARGET) $(OBJS) -lraylib -lGL -lm -lkosutils
23 |
24 | run: $(TARGET)
25 | $(KOS_LOADER) $(TARGET)
26 |
27 | dist: $(TARGET)
28 | -rm -f $(OBJS) romdisk.img
29 | $(KOS_STRIP) $(TARGET)
30 |
31 |
--------------------------------------------------------------------------------
/samples/shapes/collision_area/main.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * raylib [shapes] example - collision area
4 | *
5 | * Example originally created with raylib 2.5, last time updated with raylib 2.5
6 | *
7 | * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
8 | * BSD-like license that allows static linking with closed source software
9 | *
10 | * Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
11 | *
12 | ********************************************************************************************/
13 |
14 | #include
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define ATTR_DREAMCAST_WIDTH 640
22 | #define ATTR_DREAMCAST_HEIGHT 480
23 | bool flag=true;
24 | bool xflag=false;
25 | maple_device_t *cont;
26 | cont_state_t *pad_state;
27 | int x;
28 | int y;
29 |
30 | void updateController()
31 | {
32 | cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
33 |
34 | if(cont)
35 | {
36 | pad_state = (cont_state_t *)maple_dev_status(cont);
37 |
38 | if(!pad_state)
39 | {
40 | printf("Error reading controller\n");
41 | }
42 |
43 | if(pad_state->buttons & CONT_START)
44 | {
45 | flag=0;
46 | }
47 |
48 | if(pad_state->buttons & CONT_DPAD_UP)
49 | {
50 | y=y-10;
51 | }
52 |
53 | if(pad_state->buttons & CONT_DPAD_DOWN)
54 | {
55 | y=y+10;
56 | }
57 |
58 | if(pad_state->buttons & CONT_DPAD_RIGHT)
59 | {
60 | x=x+10;
61 | }
62 |
63 | if(pad_state->buttons & CONT_DPAD_LEFT)
64 | {
65 | x=x-10;
66 | }
67 |
68 |
69 |
70 | if(pad_state->buttons & CONT_A)
71 | {
72 | xflag = !xflag;
73 | }
74 | }
75 | }
76 |
77 | bool initApp()
78 | {
79 | return true;
80 | }
81 | void finishApp()
82 | {
83 |
84 |
85 | }
86 | //------------------------------------------------------------------------------------
87 | // Program main entry point
88 | //------------------------------------------------------------------------------------
89 | int main(void)
90 | {
91 | // Initialization
92 | //--------------------------------------------------------------------------------------
93 | const int screenWidth = ATTR_DREAMCAST_WIDTH;
94 | const int screenHeight = ATTR_DREAMCAST_HEIGHT;
95 |
96 | InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib collision area");
97 |
98 |
99 | // Box A: Moving box
100 | Rectangle boxA = { 10, GetScreenHeight()/2.0f - 50, 200, 100 };
101 | int boxASpeedX = 4;
102 |
103 | // Box B: Mouse moved box
104 |
105 | x=screenWidth/2;
106 | y=screenHeight/2;
107 |
108 | Rectangle boxCollision = { 0 }; // Collision rectangle
109 | Rectangle boxB= { GetScreenWidth()/2.0f - 30, GetScreenHeight()/2.0f - 30, 60, 60 };
110 |
111 | int screenUpperLimit = 40; // Top menu limits
112 |
113 |
114 | bool collision = false; // Collision detection
115 |
116 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second
117 | //----------------------------------------------------------
118 |
119 | // Main game loop
120 | while (flag) // Detect window close button or ESC key
121 | {
122 | // Update
123 | //-----------------------------------------------------
124 | updateController();
125 |
126 |
127 | // Move box if not paused
128 | if (!xflag) boxA.x += boxASpeedX;
129 |
130 | // Bounce box on x screen limits
131 | if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1;
132 |
133 | // Update player-controlled-box (box02)
134 | boxB.x = x - boxB.width/2;
135 | boxB.y = y - boxB.height/2;
136 |
137 | // Make sure Box B does not go out of move area limits
138 | if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width;
139 | else if (boxB.x <= 0) boxB.x = 0;
140 |
141 | if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height;
142 | else if (boxB.y <= screenUpperLimit) boxB.y = (float)screenUpperLimit;
143 |
144 | // Check boxes collision
145 | collision = CheckCollisionRecs(boxA, boxB);
146 |
147 | // Get collision rectangle (only on collision)
148 | if (collision) boxCollision = GetCollisionRec(boxA, boxB);
149 |
150 | //-----------------------------------------------------
151 |
152 | // Draw
153 | //-----------------------------------------------------
154 | BeginDrawing();
155 |
156 | ClearBackground(RAYWHITE);
157 |
158 | DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision? RED : BLACK);
159 |
160 | DrawRectangleRec(boxA, GOLD);
161 | DrawRectangleRec(boxB, BLUE);
162 |
163 | if (collision)
164 | {
165 | // Draw collision area
166 | DrawRectangleRec(boxCollision, LIME);
167 |
168 | // Draw collision message
169 | DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK);
170 |
171 | // Draw collision area
172 | DrawText(TextFormat("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK);
173 | }
174 |
175 | // Draw help instructions
176 | DrawText("Press A to PAUSE/RESUME", 20, screenHeight - 35, 20, LIGHTGRAY);
177 |
178 | DrawFPS(10, 10);
179 |
180 | EndDrawing();
181 | //-----------------------------------------------------
182 | }
183 |
184 | // De-Initialization
185 | //---------------------------------------------------------
186 | CloseWindow(); // Close window and OpenGL context
187 | //----------------------------------------------------------
188 |
189 | finishApp();
190 | return 0;
191 | }
192 |
--------------------------------------------------------------------------------
/samples/shapes/collision_area/romdisk/empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/psxdev/raylib4Dreamcast/14f4d94cd9988c180c0ece64647d14e3515c1191/samples/shapes/collision_area/romdisk/empty
--------------------------------------------------------------------------------
/samples/shapes/logo_raylib_anim/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # KallistiGL test program
3 | # (c)2013-2014 Josh PH3NOM Pearson
4 | # (c)2001 Megan Potter
5 | #
6 |
7 | TARGET = raylib.elf
8 | OBJS = main.o romdisk.o
9 | KOS_ROMDISK_DIR = romdisk
10 |
11 | all: rm-elf $(TARGET)
12 |
13 | include $(KOS_BASE)/Makefile.rules
14 |
15 | clean: rm-elf
16 | -rm -f $(OBJS)
17 |
18 | rm-elf:
19 | -rm -f $(TARGET) romdisk.*
20 |
21 | $(TARGET): $(OBJS)
22 | kos-cc -o $(TARGET) $(OBJS) -lraylib -lGL -lm -lkosutils
23 |
24 | run: $(TARGET)
25 | $(KOS_LOADER) $(TARGET)
26 |
27 | dist: $(TARGET)
28 | -rm -f $(OBJS) romdisk.img
29 | $(KOS_STRIP) $(TARGET)
30 |
31 |
--------------------------------------------------------------------------------
/samples/shapes/logo_raylib_anim/main.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************************
2 | *
3 | * raylib [shapes] example - raylib logo animation
4 | *
5 | * Example originally created with raylib 2.5, last time updated with raylib 4.0
6 | *
7 | * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
8 | * BSD-like license that allows static linking with closed source software
9 | *
10 | * Copyright (c) 2014-2023 Ramon Santamaria (@raysan5)
11 | *
12 | ********************************************************************************************/
13 |
14 | #include
15 |
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #define ATTR_DREAMCAST_WIDTH 640
22 | #define ATTR_DREAMCAST_HEIGHT 480
23 | bool flag=true;
24 | bool l1flag=false;
25 | bool r1flag=false;
26 | int xflag;
27 | maple_device_t *cont;
28 | cont_state_t *pad_state;
29 | void updateController()
30 | {
31 | cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
32 |
33 | if(cont)
34 | {
35 | pad_state = (cont_state_t *)maple_dev_status(cont);
36 |
37 | if(!pad_state)
38 | {
39 | printf("Error reading controller\n");
40 | }
41 |
42 | if(pad_state->buttons & CONT_START)
43 | {
44 | flag=0;
45 | }
46 |
47 |
48 | if(pad_state->buttons & CONT_A)
49 | {
50 | xflag=1;
51 | }
52 | }
53 | }
54 |
55 | bool initApp()
56 | {
57 | return true;
58 | }
59 | void finishApp()
60 | {
61 |
62 |
63 | }
64 | extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap);
65 |
66 | //------------------------------------------------------------------------------------
67 | // Program main entry point
68 | //------------------------------------------------------------------------------------
69 | int main(void)
70 | {
71 | // Initialization
72 | //--------------------------------------------------------------------------------------
73 | const int screenWidth = ATTR_DREAMCAST_WIDTH;
74 | const int screenHeight = ATTR_DREAMCAST_HEIGHT;
75 |
76 | InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation");
77 | //TRACELOG(LOG_INFO, "PLATFORM: calling dreamcast gl init");
78 | //glKosInit();
79 | int logoPositionX = screenWidth/2 - 128;
80 | int logoPositionY = screenHeight/2 - 128;
81 |
82 | int framesCounter = 0;
83 | int lettersCount = 0;
84 |
85 | int topSideRecWidth = 16;
86 | int leftSideRecHeight = 16;
87 |
88 | int bottomSideRecWidth = 16;
89 | int rightSideRecHeight = 16;
90 |
91 | int state = 0; // Tracking animation states (State Machine)
92 | float alpha = 1.0f; // Useful for fading
93 |
94 |
95 |
96 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second
97 | //--------------------------------------------------------------------------------------
98 |
99 |
100 | // Main game loop
101 | while (flag) // Detect window close button or ESC key
102 | {
103 | // Update
104 | //----------------------------------------------------------------------------------
105 | updateController();
106 |
107 |
108 | if (state == 0) // State 0: Small box blinking
109 | {
110 | framesCounter++;
111 |
112 | if (framesCounter == 120)
113 | {
114 | state = 1;
115 | framesCounter = 0; // Reset counter... will be used later...
116 | }
117 | }
118 | else if (state == 1) // State 1: Top and left bars growing
119 | {
120 | topSideRecWidth += 4;
121 | leftSideRecHeight += 4;
122 |
123 | if (topSideRecWidth == 256) state = 2;
124 | }
125 | else if (state == 2) // State 2: Bottom and right bars growing
126 | {
127 | bottomSideRecWidth += 4;
128 | rightSideRecHeight += 4;
129 |
130 | if (bottomSideRecWidth == 256) state = 3;
131 | }
132 | else if (state == 3) // State 3: Letters appearing (one by one)
133 | {
134 | framesCounter++;
135 |
136 | if (framesCounter/12) // Every 12 frames, one more letter!
137 | {
138 | lettersCount++;
139 | framesCounter = 0;
140 | }
141 |
142 | if (lettersCount >= 10) // When all letters have appeared, just fade out everything
143 | {
144 | alpha -= 0.02f;
145 |
146 | if (alpha <= 0.0f)
147 | {
148 | alpha = 0.0f;
149 | state = 4;
150 | }
151 | }
152 | }
153 | else if (state == 4) // State 4: Reset and Replay
154 | {
155 | if (xflag)
156 | {
157 | framesCounter = 0;
158 | lettersCount = 0;
159 |
160 | topSideRecWidth = 16;
161 | leftSideRecHeight = 16;
162 |
163 | bottomSideRecWidth = 16;
164 | rightSideRecHeight = 16;
165 |
166 | alpha = 1.0f;
167 | state = 0; // Return to State 0
168 | xflag = 0;
169 | }
170 | }
171 |
172 | //----------------------------------------------------------------------------------
173 |
174 | // Draw
175 | //----------------------------------------------------------------------------------
176 | BeginDrawing();
177 | ClearBackground(RAYWHITE);
178 |
179 | if (state == 0)
180 | {
181 | if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK);
182 | }
183 | else if (state == 1)
184 | {
185 | DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
186 | DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
187 | }
188 | else if (state == 2)
189 | {
190 | DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
191 | DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
192 |
193 | DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK);
194 | DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK);
195 | }
196 | else if (state == 3)
197 | {
198 | DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
199 | DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
200 |
201 | DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
202 | DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
203 |
204 | DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
205 | DrawText(TextSubtext("raylib", 0, lettersCount), GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha));
206 | }
207 | else if (state == 4)
208 | {
209 | DrawText("powered by raylib4Dreamcast [A] REPLAY", screenWidth/2-200, screenHeight/2-38, 20, GRAY);
210 | }
211 | EndDrawing();
212 | //----------------------------------------------------------------------------------
213 | }
214 |
215 | // De-Initialization
216 | //--------------------------------------------------------------------------------------
217 | CloseWindow(); // Close window and OpenGL context
218 | //--------------------------------------------------------------------------------------
219 | finishApp();
220 | return 0;
221 | }
222 |
--------------------------------------------------------------------------------
/samples/shapes/logo_raylib_anim/romdisk/empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/psxdev/raylib4Dreamcast/14f4d94cd9988c180c0ece64647d14e3515c1191/samples/shapes/logo_raylib_anim/romdisk/empty
--------------------------------------------------------------------------------