Wiki feedback

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
bogglez
Moderator
Moderator
Posts: 578
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Wiki feedback

Post by bogglez »

Hello,

I have some free time on my hands and thought it would be a good idea to convert some forum posts to wiki entries to avoid redundant questions and make it easier for people to get into DC development.
So if there's anything you would like a tutorial on, please ask for it here and we can figure out who is capable of writing a wiki entry for it.
If you want to help, you can hunt for old tutorials on the forums and link them here, so we can update and convert them to a wiki entry.
I will add your suggestions to this list.

Link to the wiki page with tutorials: http://dcemulation.org/?title=Development

Wiki entries to write:
  • IRC channel (bogglez, old page)
Setup
  • Compiling KOS on Windows (bogglez) (some issues on Windows, need help)
  • Compiling KOS on OS X
  • Compiling KOS on Linux (bogglez)
General
  • About the CPU (store queues, DMA) (bogglez, old tutorial) (stub)
  • Memory map (bogglez, from Marcus Comstedt's website)
  • Efficient usage of the Dreamcast RAM (bogglez, from http://dev.dcemulation.org/tutorials/me ... zation.htm)
  • How to obtain controller inputs
  • How to read data (romdisk, cd, vmu) (bogglez, tutorial by emptythought from '08) (only VMU part, needs verification)
  • Video: Hardware Architecture Breakdown (https://www.youtube.com/watch?v=1_XhD5Msurc by Nexus Externi)
  • Romdisk Swapping (by Lerabot)
Graphics
  • About the DC graphics hardware
  • PVR API vs OpenGL vs software rendering (bogglez, need feedback)
  • About PVR texture formats and compression (bogglez, need feedback)
  • Rendering geometry efficiently

    PVR
  • 2D rendering without using the PVR graphics chip (bogglez, old page, tutorial by BlackAura) (check whether up-to-date)
  • How to load and display paletted textures (bogglez, tutorial by BlackAura) (check correctness)
  • Creating and loading KMG textures (bogglez) (need feedback)
  • Spritesheet animation with PVR (bogglez) (need feedback)
  • OpenGL
  • Loading PNG images as OpenGL textures
Sound and Music
  • About the DC sound hardware
  • How to play sounds
  • How to stream music
Deployment
  • About IP.bin 1st.bin and scrambling
  • Burning a game to disc
  • Transfer over serial, modem or BBA
VMU and other accessories
  • Writing programs for the VMU
  • Making the VMU beep
  • Rumble
FAQs
  • Porting FAQs (bogglez, Schnapple's and DirtySanchez's FAQ from '02) (needs up-to-date check)
Last edited by bogglez on Thu Sep 15, 2016 12:56 pm, edited 33 times in total.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
tonma
DCEmu Freak
DCEmu Freak
Posts: 82
Joined: Thu Mar 10, 2016 7:14 am
Has thanked: 0
Been thanked: 1 time

Re: Wiki feedback

Post by tonma »

I agree with that. As I'm new, I will certainly ask the same questions again, but I make some search before on forum :mrgreen:

I think Compiling KOS on Windows will be great for other newcomers.
The biggest problems for me are video memory occupation and drawing texture with 16,8,4-bit. And Threading to load data while playing.

I finally find a tuto about the texture loading but I can not get it to work.
viewtopic.php?f=29&t=99166
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

Could somebody please write the "Transfer over serial, modem or BBA" tutorial? I don't use that method.

http://dcemulation.org/index.php?title= ... _Dreamcast

This is the old tutorial (it's pretty much useless I assume).
Spoiler!
==dcload==

'''NOTE: This section is still incomplete!

The dcload package is a pair of programs, dc-tool and dcload, that allow you to upload and run your programs on the Dreamcast. dcload is burned onto a CDROM and run on the Dreamcast. After it starts, it waits for dc-tool on the PC to communicate and upload data.

Two versions of the dcload package exist: dcload-ip, which works over an ethernet connection (BBA, Lan adapter), and dcload-serial, which works over a serial port connection (Coders cable, USB cables).

I will only cover dcload-serial here. The process for dcload-ip should be similar though.

First we download the latest version from the subversion repository:

$ svn co https://cadcdev.svn.sourceforge.net/svn ... oad-serial

Next we have to edit Makefile.cfg. Three settings are important here:

HOSTCC sets the compiler that should be used to create the tool that will run on your PC. Again we have to use GCC <= 3.4.

HOSTCC = gcc-3.4

TARGETPREFIX tells the compiler where to find the toolchain.

TARGETPREFIX = /home/foobert/dc/sh-elf

Finally, TOOLINSTALLDIR tells make where to install the tools.

TOOLINSTALLDIR = /home/foobert/dc/bin

Now we can compile and install:
$ make
$ make install

dc-tool should now be available in /home/foobert/dc/bin.

In target-src/1st_read, you will find the binary that is to be burned onto CDROM and booted on the Dreamcast.

For now I will not cover how to burn the CDROM. The Makefile in make-cd did not work for me the last time I tried it, so I ended up doing it manually. You also need the scramble utility for the process to work.

Check the net and the usual Dreamcast communities for info on how to burn bootable CDROMS.

I might add this info in a later revision of this tutorial.
And dc-load
Spoiler!
DC-LOAD is the server program meant to be run on the Sega Dreamcast. DC-Load is part of the set of DC-Tool / DC-Load combination. See the DC-Tool for more information on running this setup. To be used, you must have a way to connect your Dreamcast console to your computer, it can be one of the following:

A Coders Cable (a serial cable, the historical way to do that)
A Broadband Adapter, often shortened as “BBA” (a 10/100Mbits network Ethernet card).
This program, originally developed by ADK/Napalm and now full part of the KallistiOS library (used in the homebrew developments targeted to the Sega Dreamcast) is split in two packages:

DC-LOAD, the server part, started from the Dreamcast
DC-TOOL, the client part, started from the computer (can be GNU/Linux or Windows).
Depending on the method chosen (Coders Cable or BBA) you must use the right version of the program:

DC-LOAD or DC-LOAD-SERIAL for the Coders Cable version
DC-LOAD-IP for the BBA version

I converted Ph3nom's cygwin tutorial but I don't know whether it works (especially since it uses 2.0 + some patches instead of git), so feedback would be appreciated:
http://dcemulation.org/?title=Compiling_KOS_on_Windows


I had a look at the PVR document, and think it should be rewritten. It explains a poor way of geometry submission that should not be used (pvr_prim). People who want an easy way to do graphics should use OpenGL anyway.
I think the PVR article should explain concepts like display lists (in more detail), modifier volumes, the command queue, polygon contexts, fixed pipeline functionality (culling etc) and proper geometry submission (store queue or dma).


Regarding the filesystem:
I found this mount tutorial by BlackAura, but I'm unsure whether I should include it.. does anybody use romdisks as files? It's also a bit lacking in info about the general filesystem and VMU info..
viewtopic.php?f=29&t=68795#p744100


VMU Beep: viewtopic.php?f=29&t=97048


Haven't finished sifting through this entirely yet: viewtopic.php?f=29&t=100002


And with that I'm done for today and will wait for some reactions. :-)
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

I've added the tutorial "Creating and loading KMG textures" to graphics http://dcemulation.org/?title=KMG_Textures
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

tonma wrote:The biggest problems for me are video memory occupation and drawing texture with 16,8,4-bit. And Threading to load data while playing.

I finally find a tuto about the texture loading but I can not get it to work.
viewtopic.php?f=29&t=99166
I've added a tutorial for PVR spritesheet animation: http://dcemulation.org/?title=PVR_Spritesheets

I hope it answers some of your questions.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

The Memory Map article was very minimalistic, so I've copied the article from Marcus Comstedt's website with his permission: http://dcemulation.org/?title=Dreamcast_Memory_Map
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 5 times

Re: Wiki feedback

Post by nymus »

It's nice to know that a pioneer such as Marcus Comstedt is still reachable. Good Work btw.
behold the mind
inspired by Dreamcast
|darc|
DCEmu Webmaster
DCEmu Webmaster
Posts: 16373
Joined: Wed Mar 14, 2001 6:00 pm
Location: New Orleans, LA
Has thanked: 103 times
Been thanked: 90 times
Contact:

Re: Wiki feedback

Post by |darc| »

It actually hasn't been that long since he's been active in the DC scene. The most recent version of dc-virtcd was released about 4 years ago.
It's thinking...
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 5 times

Re: Wiki feedback

Post by nymus »

From the very beginning I have been the desire to make some kind of Dreamcast history movie and this wiki would be useful.

Ours is quite the epic tale with plenty of drama with lots of interesting personalities, conflicts...
behold the mind
inspired by Dreamcast
tonma
DCEmu Freak
DCEmu Freak
Posts: 82
Joined: Thu Mar 10, 2016 7:14 am
Has thanked: 0
Been thanked: 1 time

Re: Wiki feedback

Post by tonma »

Hi,

I have some questions about the code / tutorial " PVR spritesheet animation".

In this part :

Code: Select all

/* Draw animated enemies */
	uint8_t sprite_number = (unsigned)(0.01f * timer_ms_gettime64()) % 8;
	char sprite_name[32];
	snprintf(sprite_name, sizeof(sprite_name), "mage_combat%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 100, 300, stage1_actors_palette_number);

	snprintf(sprite_name, sizeof(sprite_name), "mage_shadowform%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 250, 300, stage1_actors_palette_number);

	snprintf(sprite_name, sizeof(sprite_name), "mage_idle%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 350, 300, stage1_actors_palette_number);
Why do you use "sprite_name[31] = 0;" And always the value 31 ? I understand sprite_name is the char array of the sprite_name but after :oops:


And I wish to use PAL4BPP image to load more images :
I change the setup_palette to load th good palette number and in the draw_sprite function, I change :

Code: Select all

pvr_poly_cxt_txr(&context, PVR_LIST_PT_POLY, PVR_TXRFMT_PAL4BPP | PVR_TXRFMT_4BPP_PAL(palette_number), sheet->width, sheet->height, sheet->texture, PVR_FILTER_NONE);
The emulator crash when it comes to the spritesheet_load function at :

Code: Select all

/* Only allow 8 bit palette dtex files */
	if(memcmp(dtex_header.magic, "DTEX", 4) || dtex_header.type != 0x30000000) {
		result = 3;
		goto cleanup;
	}
How can I allow 4 bit pallette ?
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

tonma wrote:Hi,

I have some questions about the code / tutorial " PVR spritesheet animation".

In this part :

Code: Select all

/* Draw animated enemies */
	uint8_t sprite_number = (unsigned)(0.01f * timer_ms_gettime64()) % 8;
	char sprite_name[32];
	snprintf(sprite_name, sizeof(sprite_name), "mage_combat%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 100, 300, stage1_actors_palette_number);

	snprintf(sprite_name, sizeof(sprite_name), "mage_shadowform%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 250, 300, stage1_actors_palette_number);

	snprintf(sprite_name, sizeof(sprite_name), "mage_idle%u", sprite_number);
	sprite_name[31] = 0;
	draw_sprite(&stage1_actors_sheet, sprite_name, 350, 300, stage1_actors_palette_number);
Why do you use "sprite_name[31] = 0;" And always the value 31 ? I understand sprite_name is the char array of the sprite_name but after :oops:
This is a problem with C's snprintf. When you write char * string = "foo"; in C, it's basically a shortcut for char string[] = {'f', 'o', 'o', 0}.
String functions will then use the 0 to detect the end of the string.
sprite_name is defined as an array of 32 chars, their indices are 0..31 (you need to count index 0 as well, so indices 1..31 = 31 chars, plus index 0 = 32).
snprintf will copy one string to another, it will then add a 0 to the end. However, it will not do that if there is not enough space.
If it copies a full 32 characters and you do something like puts(sprite_name);, the function will not know where the end of the string is and it will read memory past the end, which will cause all kinds of problems.
That's why I just said "the last character must be 0". Basically I'm cutting the string off if it is too long.
A more solid way would be to detect that the string generated by snprintf is too long for its destination sprite_name and error out, but I took the easy way out for the tutorial.
tonma wrote: And I wish to use PAL4BPP image to load more images :
I change the setup_palette to load th good palette number and in the draw_sprite function, I change :

Code: Select all

pvr_poly_cxt_txr(&context, PVR_LIST_PT_POLY, PVR_TXRFMT_PAL4BPP | PVR_TXRFMT_4BPP_PAL(palette_number), sheet->width, sheet->height, sheet->texture, PVR_FILTER_NONE);
The emulator crash when it comes to the spritesheet_load function at :

Code: Select all

/* Only allow 8 bit palette dtex files */
	if(memcmp(dtex_header.magic, "DTEX", 4) || dtex_header.type != 0x30000000) {
		result = 3;
		goto cleanup;
	}
How can I allow 4 bit pallette ?
In the tutorial I mentioned "The DTEX and DPAL file formats are documented in texconv's readme", which you can find here: https://github.com/tvspelsfreak/texconv ... readme.txt
Read the section "TEXTURE FILE FORMAT".
The first 8 bytes are id, width and height, then you find the "type".

Code: Select all

bits 27-29 : Pixel format
...
	5 = PAL4BPP
	6 = PAL8BPP
0x30000000 is 0b110000000000000000000000000000, in other words 6 = 0b110 shifted 27 bits to the left.
5 is 0b101 so I think you need 5 << 27 = 0x28000000.
You can verify this with a hex editor.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
tonma
DCEmu Freak
DCEmu Freak
Posts: 82
Joined: Thu Mar 10, 2016 7:14 am
Has thanked: 0
Been thanked: 1 time

Re: Wiki feedback

Post by tonma »

Thank you so much, it's clearer for my little brain. :oops: I still have much to learn.

My other modifications work perfectly. I can mix between palettes. :mrgreen:
tonma
DCEmu Freak
DCEmu Freak
Posts: 82
Joined: Thu Mar 10, 2016 7:14 am
Has thanked: 0
Been thanked: 1 time

Re: Wiki feedback

Post by tonma »

For the tutorial "PVR spritesheet animation". I found a bug if you load spritesheet again and again.

You forgot the fclose at the end of the function spriteheet_load :

Code: Select all

if(image_file)   fclose(image_file);
if(palette_file) fclose(palette_file);
if(sheet_file)   fclose(sheet_file);
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

tonma, thank you for pointing that out.
I only called fclose upon error. Obviously I did not test that function at all.. I was even considering not putting it in at all out of laziness. Sorry for causing confusion :)

Code: Select all

Fix: fclose in spritesheet_free() upon success as well
add comment for TexturePacker divisor
add converted files and executable so that no compilation/conversion is necessary
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
tonma
DCEmu Freak
DCEmu Freak
Posts: 82
Joined: Thu Mar 10, 2016 7:14 am
Has thanked: 0
Been thanked: 1 time

Re: Wiki feedback

Post by tonma »

No problem. It allows me to learn :mrgreen:
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: Wiki feedback

Post by bbmario »

That wiki is priceless. :)
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

I added "Compiling KOS on OS X" and uploaded the kos_setup_script.sh to the wiki, also added it to the Linux guide.
If there are any issues with the installer in the future, you may just update that shell script.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

Made two changes to the installer script:
- Disallow root. The script should be run as sh kos_setup_script.sh. A user was confused by his web browser being opened as root when opening the documentation at the end of the script.
- Check for required software at start, to save people from bad surprises later (I was missing makeinfo on a fresh Debian machine..). I think I've covered most required programs but surely not all.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Wiki feedback

Post by bogglez »

I've rewritten the "Compiling on Windows" tutorial, it uses MSYS2 now instead of Cygwin. I've also updated the script for Linux/Mac/Windows.

Changes to the script:
  • Support for MSYS2 Windows builds
  • Check for more required programs
  • Auto-install packages on Fedora (untested)
  • Auto-install packages on Debian
  • Download new config.{guess,sub} to detect more systems in autoconf
  • Documentation will also open in firefox or chromium if x-www-browser is not installed.
I'd appreciate if somebody could try the installer on Windows, Debian-derived systems, Fedora and everything else you can throw at it.
Up to now it has been tested on Debian 64 bit, OSX 10.7 64 bit, Windows XP 32 bit and Ubuntu (to my knowledge).

The old Cygwin tutorial I assembled from a forum post by ph3nom is at the bottom of the page.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: Wiki feedback

Post by BlueCrab »

I've edited the page to point out that the dev iso and code::blocks setups are extremely old and shouldn't be used for any current development.

I'd really rather not have a bunch of questions from people using them and running into problems again (that's why I unstuck the topics from this forum a while back). The way the page was phrased at that section made it seem like we were recommending them, which would not be something we should be doing (unless someone really does want to support really old versions of stuff -- I know that I don't).
Post Reply