You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(26) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Donald H. <qu...@us...> - 2014-09-07 18:29:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 44a62b490650c4da1fd386da594204aded37e9e1 (commit) from 15e2b89b3ddf9ceedd1960c5c3d8b2ddb411efe2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 44a62b490650c4da1fd386da594204aded37e9e1 Author: Donald Haase <qu...@co...> Date: Sun Sep 7 13:14:58 2014 -0400 Updated functionality for the CDROM. Includes subcode reading, DMA sector reading, and more accessible parameters for initializing the drive. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/cdrom.c | 211 +++++++++++++++++++----------- kernel/arch/dreamcast/include/dc/cdrom.h | 121 ++++++++++++++++-- 2 files changed, 245 insertions(+), 87 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index 09e613e..ce6464e 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -4,6 +4,7 @@ Copyright (C) 2000 Dan Potter Copyright (C) 2014 Lawrence Sebald + Copyright (C) 2014 Donald Haase */ @@ -32,13 +33,14 @@ they require their parameters to be in certain registers, which is normally the case with the default options. If in doubt, decompile the output and look to make sure. +XXX: This could all be done in a non-blocking way by taking advantage of +command queuing. Every call to gdc_req_cmd returns a 'request id' which +just needs to eventually be checked by cmd_stat. A non-blocking version +of all functions would simply require manual calls to check the status. +Doing this would probably allow data reading while cdda is playing without +hiccups (by severely reducing the number of gd commands being sent). */ -/* Parts of the a CD-ROM sector to read. These are possible values for the - third parameter word sent with the change data type syscall. */ -#define CDROM_READ_WHOLE_SECTOR 0x1000 -#define CDROM_READ_DATA_AREA 0x2000 - /* GD-Rom BIOS calls... named mostly after Marcus' code. None have more than two parameters; R7 (fourth parameter) needs to describe @@ -79,10 +81,9 @@ static int gdc_change_data_type(void *param) { MAKE_SYSCALL(return, param, 0, 10); } -/* These two functions are never actually used in here. They're only really here - for reference at this point. */ -#if 0 /* Reset the GD-ROM */ +/* Stop gcc from complaining that we don't use it */ +static void gdc_reset() __attribute__((unused)); static void gdc_reset() { MAKE_SYSCALL(/**/, 0, 0, 9); } @@ -91,20 +92,21 @@ static void gdc_reset() { static void gdc_abort_cmd(int cmd) { MAKE_SYSCALL(/**/, cmd, 0, 8); } -#endif -/* The CD access mutex */ -mutex_t _g1_ata_mutex; -static int initted = 0; -static int sector_size = 2048; /*default 2048, 2352 for raw data reading*/ +/* The G1 ATA access mutex */ +mutex_t _g1_ata_mutex = RECURSIVE_MUTEX_INITIALIZER; -void cdrom_set_sector_size(int size) { - sector_size = size; - cdrom_reinit(); +/* Shortcut to cdrom_reinit_ex. Typically this is the only thing changed. */ +int cdrom_set_sector_size(int size) { + return cdrom_reinit_ex(-1, -1, size); } /* Command execution sequence */ -int cdrom_exec_cmd(int cmd, void *param) { +/* XXX: It might make sense to have a version of this that takes a timeout. + The only time this could cause an issue is if for some inane reason a user + were to cdrom_init/reinit in one thread and expect to be able to get a + reliable read in another. */ +static int cdrom_exec_cmd(int cmd, void *param) { int status[4] = {0}; int f, n; @@ -151,6 +153,7 @@ int cdrom_get_status(int *status, int *disc_type) { already in progress. */ if(irq_inside_int()) { if(mutex_trylock(&_g1_ata_mutex)) + /* DH: Figure out a better return to signal error */ return -1; } else { @@ -161,6 +164,7 @@ int cdrom_get_status(int *status, int *disc_type) { g1_ata_select_device(G1_ATA_MASTER); rv = gdc_get_drv_stat(params); + mutex_unlock(&_g1_ata_mutex); if(rv >= 0) { if(status != NULL) @@ -177,16 +181,58 @@ int cdrom_get_status(int *status, int *disc_type) { *disc_type = -1; } - mutex_unlock(&_g1_ata_mutex); + return rv; +} + +/* Wrapper for the change datatype syscall */ +int cdrom_change_dataype(int sector_part, int cdxa, int sector_size) { + int rv = ERR_OK; + uint32 params[4]; + + mutex_lock(&_g1_ata_mutex); + g1_ata_select_device(G1_ATA_MASTER); + + /* Check if we are using default params */ + if(sector_size == 2352) { + if(cdxa == -1) + cdxa = 0; + + if(sector_part == -1) + sector_part = CDROM_READ_WHOLE_SECTOR; + } + else { + if(cdxa == -1) { + /* If not overriding cdxa, check what the drive thinks we should + use */ + gdc_get_drv_stat(params); + cdxa = (params[1] == 32 ? 2048 : 1024); + } + if(sector_part == -1) + sector_part = CDROM_READ_DATA_AREA; + + if(sector_size == -1) + sector_size = 2048; + } + + params[0] = 0; /* 0 = set, 1 = get */ + params[1] = sector_part; /* Get Data or Full Sector */ + params[2] = cdxa; /* CD-XA mode 1/2 */ + params[3] = sector_size; /* sector size */ + rv = gdc_change_data_type(params); + mutex_unlock(&_g1_ata_mutex); return rv; } /* Re-init the drive, e.g., after a disc change, etc */ int cdrom_reinit() { - int rv = ERR_OK; - int r = -1, cdxa; - uint32 params[4]; + /* By setting -1 to each parameter, they fall to the old defaults */ + return cdrom_reinit_ex(-1, -1, -1); +} + +/* Enhanced cdrom_reinit, takes the place of the old 'sector_size' function */ +int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size) { + int r = -1; int timeout; mutex_lock(&_g1_ata_mutex); @@ -204,12 +250,12 @@ int cdrom_reinit() { if(r == 0) break; if(r == ERR_NO_DISC) { - rv = r; - goto exit; + mutex_unlock(&_g1_ata_mutex); + return r; } else if(r == ERR_SYS) { - rv = r; - goto exit; + mutex_unlock(&_g1_ata_mutex); + return r; } /* Still trying.. sleep a bit and check again */ @@ -218,34 +264,16 @@ int cdrom_reinit() { } if(timeout <= 0) { - rv = r; - goto exit; + /* Send an abort since we're giving up waiting for the init */ + gdc_abort_cmd(CMD_INIT); + mutex_unlock(&_g1_ata_mutex); + return r; } - /* Check disc type and set parameters */ - gdc_get_drv_stat(params); - if(sector_size != 2352) { - cdxa = params[1] == 32; - params[0] = 0; /* 0 = set, 1 = get */ - params[1] = CDROM_READ_DATA_AREA; /* Part of the sector to read */ - params[2] = cdxa ? 2048 : 1024; /* Sector type */ - params[3] = sector_size; /* Sector size */ - } - else { - params[0] = 0; - params[1] = CDROM_READ_WHOLE_SECTOR; - params[2] = 0; - params[3] = 2352; - } - - if(gdc_change_data_type(params) < 0) { - rv = ERR_SYS; - goto exit; - } - -exit: + r = cdrom_change_dataype(sector_part, cdxa, sector_size); mutex_unlock(&_g1_ata_mutex); - return rv; + + return r; } /* Read the table of contents */ @@ -256,37 +284,75 @@ int cdrom_read_toc(CDROM_TOC *toc_buffer, int session) { } params; int rv; - mutex_lock(&_g1_ata_mutex); - params.session = session; params.buffer = toc_buffer; - rv = cdrom_exec_cmd(CMD_GETTOC2, ¶ms); + mutex_lock(&_g1_ata_mutex); + + rv = cdrom_exec_cmd(CMD_GETTOC2, ¶ms); mutex_unlock(&_g1_ata_mutex); + return rv; } -/* Read one or more sectors */ -int cdrom_read_sectors(void *buffer, int sector, int cnt) { +/* Enhanced Sector reading: Choose mode to read in. */ +int cdrom_read_sectors_ex(void *buffer, int sector, int cnt, int mode) { struct { int sec, num; void *buffer; int dunno; } params; - int rv; - - mutex_lock(&_g1_ata_mutex); + int rv = ERR_OK; params.sec = sector; /* Starting sector */ - params.num = cnt; /* Number of sectors */ + params.num = cnt; /* Number of sectors */ params.buffer = buffer; /* Output buffer */ - params.dunno = 0; /* ? */ - rv = cdrom_exec_cmd(CMD_PIOREAD, ¶ms); + params.dunno = 0; /* ? */ + + mutex_lock(&_g1_ata_mutex); + + /* The DMA mode blocks the thread it is called in by the way we execute + gd syscalls. It does however allow for other threads to run. */ + /* XXX: DMA Mode may conflict with using a second G1ATA device. More + testing is needed from someone with such a device. + */ + if(mode == CDROM_READ_DMA) + rv = cdrom_exec_cmd(CMD_DMAREAD, ¶ms); + else if (mode == CDROM_READ_PIO) + rv = cdrom_exec_cmd(CMD_PIOREAD, ¶ms); mutex_unlock(&_g1_ata_mutex); return rv; } +/* Basic old sector read */ +int cdrom_read_sectors(void *buffer, int sector, int cnt) { + return cdrom_read_sectors_ex(buffer, sector, cnt, CDROM_READ_PIO); +} + + +/* Read a piece of or all of the Q byte of the subcode of the last sector read. + If you need the subcode from every sector, you cannot read more than one at + a time. */ +/* XXX: Use some CD-Gs and other stuff to test if you get more than just the + Q byte */ +int cdrom_get_subcode(void *buffer, int buflen, int which) { + struct { + int which; + int buflen; + void *buffer; + } params; + int rv; + + params.which = which; + params.buflen = buflen; + params.buffer = buffer; + mutex_lock(&_g1_ata_mutex); + rv = cdrom_exec_cmd(CMD_GETSCD, ¶ms); + mutex_unlock(&_g1_ata_mutex); + return rv; +} + /* Locate the LBA sector of the data track; use after reading TOC */ uint32 cdrom_locate_data_track(CDROM_TOC *toc) { int i, first, last; @@ -318,7 +384,7 @@ int cdrom_cdda_play(uint32 start, uint32 end, uint32 repeat, int mode) { int end; int repeat; } params; - int rv; + int rv = ERR_OK; /* Limit to 0-15 */ if(repeat > 15) @@ -332,7 +398,7 @@ int cdrom_cdda_play(uint32 start, uint32 end, uint32 repeat, int mode) { if(mode == CDDA_TRACKS) rv = cdrom_exec_cmd(CMD_PLAY, ¶ms); - else + else if(mode == CDDA_SECTORS) rv = cdrom_exec_cmd(CMD_PLAY2, ¶ms); mutex_unlock(&_g1_ata_mutex); @@ -376,28 +442,24 @@ int cdrom_spin_down() { /* Initialize: assume no threading issues */ int cdrom_init() { uint32 p; - volatile uint32 *react = (uint32*)0xa05f74e4, - *bios = (uint32*)0xa0000000; - - if(initted) - return -1; + volatile uint32 *react = (uint32 *)0xa05f74e4, + *bios = (uint32 *)0xa0000000; /* Reactivate drive: send the BIOS size and then read each word across the bus so the controller can verify it. */ *react = 0x1fffff; - for(p = 0; p < 0x200000 / 4; p++) { + for(p = 0; p < 0x200000 / sizeof(bios[0]); p++) { (void)bios[p]; } + mutex_lock(&_g1_ata_mutex); /* Make sure to select the GD-ROM drive. */ g1_ata_select_device(G1_ATA_MASTER); /* Reset system functions */ gdc_init_system(); - - /* Initialize mutex */ - mutex_init(&_g1_ata_mutex, MUTEX_TYPE_NORMAL); + mutex_unlock(&_g1_ata_mutex); /* Do an initial initialization */ cdrom_reinit(); @@ -406,9 +468,6 @@ int cdrom_init() { } void cdrom_shutdown() { - if(!initted) - return; - mutex_destroy(&_g1_ata_mutex); - initted = 0; + /* What would you want done here? */ } diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h index daa7188..038d477 100644 --- a/kernel/arch/dreamcast/include/dc/cdrom.h +++ b/kernel/arch/dreamcast/include/dc/cdrom.h @@ -1,8 +1,8 @@ /* KallistiOS ##version## dc/cdrom.h - (c)2000-2001 Dan Potter - + Copyright (C) 2000-2001 Dan Potter + Copyright (C) 2014 Donald Haase */ #ifndef __DC_CDROM_H @@ -25,8 +25,8 @@ __BEGIN_DECLS CD, it will automatically detect and react to disc changes for you. This file only facilitates reading raw sectors and doing other fairly low- - level things with CDs. If you're looking for higher-level stuff, like normal - file reading, consult with the stuff for the fs and for fs_iso9660. + level things with CDs. If you're looking for higher-level stuff, like + normal file reading, consult with the stuff for the fs and for fs_iso9660. \author Dan Potter \see kos/fs.h @@ -91,6 +91,40 @@ __BEGIN_DECLS #define CDDA_SECTORS 2 /**< \brief Play by sector number */ /** @} */ +/** \defgroup cd_read_sector_part CD-ROM Read Sector Part + + Parts of the a CD-ROM sector to read. These are possible values for the + third parameter word sent with the change data type syscall. + @{ +*/ +#define CDROM_READ_WHOLE_SECTOR 0x1000 /**< \brief Read the whole sector */ +#define CDROM_READ_DATA_AREA 0x2000 /**< \brief Read the data area */ +/** @} */ + +/** \defgroup cd_read_subcode_type CD-ROM Read Subcode Type + + Types of data available to read from the sector subcode. These are + possible values for the first parameter sent to the GETSCD syscall. + @{ +*/ +#define CD_SUB_Q_CHANNEL 0 /**< \brief Read Q Channel Subcode Data */ +#define CD_SUB_CURRENT_POSITION 1 /**< \brief Read all Subcode Data for + most recent sector */ +#define CD_SUB_MEDIA_CATALOG 2 /**< \brief Read the Media Catalog + Subcode Data */ +#define CD_SUB_TRACK_ISRC 3 /**< \brief Read the ISRC Subcode Data */ +/** @} */ + +/** \defgroup cd_read_sector_mode CD-ROM Read Sector Mode + + How to read the sectors of a CD, via PIO or DMA. 4th parameter of + cdrom_read_sectors_ex. + @{ +*/ +#define CDROM_READ_PIO 0 /**< \brief Read sector(s) in PIO mode */ +#define CDROM_READ_DMA 1 /**< \brief Read sector(s) in DMA mode */ +/** @} */ + /** \defgroup cd_status_values CD-ROM status values These are the values that can be returned as the status parameter from the @@ -170,20 +204,23 @@ typedef struct { sectors) or 2352 (for reading raw sectors). \param size The size of the sector data. + + \return \ref cd_cmd_response */ -void cdrom_set_sector_size(int size); +int cdrom_set_sector_size(int size); /** \brief Execute a CD-ROM command. This function executes the specified command using the BIOS syscall for - executing GD-ROM commands. + executing GD-ROM commands. This is *NOT* thread-safe. You must track the + G1_ATA mutex yourself. \param cmd The command number to execute. \param param Data to pass to the syscall. \return \ref cd_cmd_response */ -int cdrom_exec_cmd(int cmd, void *param); +static int cdrom_exec_cmd(int cmd, void *param); /** \brief Get the status of the GD-ROM drive. @@ -196,15 +233,48 @@ int cdrom_exec_cmd(int cmd, void *param); */ int cdrom_get_status(int *status, int *disc_type); +/** \brief Change the datatype of disc. + + This function will take in all parameters to pass to the change_datatype + syscall. This allows these parameters to be modified without a reinit. + Each parameter allows -1 as a default, which is tied to the former static + values provided by cdrom_reinit and cdrom_set_sector_size. + + \param sector_part How much of each sector to return. + \param cdxa What CDXA mode to read as (if applicable). + \param sector_size What sector size to read (eg. - 2048, 2532). + + \return \ref cd_cmd_response + \see cd_read_sector_part +*/ +int cdrom_change_dataype(int sector_part, int cdxa, int sector_size); + /** \brief Re-initialize the GD-ROM drive. - This function is for reinitializing the GD-ROM drive after a disc change, - or something of the like. + This function is for reinitializing the GD-ROM drive after a disc change to + its default settings. Calls cdrom_reinit(-1,-1,-1) \return \ref cd_cmd_response + \see cdrom_reinit_ex */ int cdrom_reinit(); +/** \brief Re-initialize the GD-ROM drive with custom parameters. + + At the end of each cdrom_reinit(), cdrom_change_datatype is called. + This passes in the requested values to that function after + reinitialization, as opposed to defaults. + + \param sector_part How much of each sector to return. + \param cdxa What CDXA mode to read as (if applicable). + \param sector_size What sector size to read (eg. - 2048, 2532). + + \return \ref cd_cmd_response + \see cd_read_sector_part + \see cdrom_change_datatype +*/ +int cdrom_reinit_ex(int sector_part, int cdxa, int sector_size); + /** \brief Read the table of contents from the disc. ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-09-03 01:23:11
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 15e2b89b3ddf9ceedd1960c5c3d8b2ddb411efe2 (commit) from 65aa964a53ae91d82ca50d3937fff95fe675bbd8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 15e2b89b3ddf9ceedd1960c5c3d8b2ddb411efe2 Author: Lawrence Sebald <ljs...@us...> Date: Tue Sep 2 21:22:25 2014 -0400 Add a new header file with compile-time options and rename several of the debugging related options in the code. ----------------------------------------------------------------------- Summary of changes: include/kos/opts.h | 113 +++++++++++++++++++++ kernel/arch/dreamcast/fs/fs_dclnative.c | 34 ++---- kernel/arch/dreamcast/hardware/pvr/pvr_mem.c | 40 +++---- kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c | 8 ++ kernel/libc/koslib/malloc.c | 19 ++-- 5 files changed, 156 insertions(+), 58 deletions(-) create mode 100644 include/kos/opts.h diff --git a/include/kos/opts.h b/include/kos/opts.h new file mode 100644 index 0000000..9e6456f --- /dev/null +++ b/include/kos/opts.h @@ -0,0 +1,113 @@ +/* KallistiOS ##version## + + kos/opts.h + Copyright (C) 2014 Lawrence Sebald +*/ + +#ifndef __KOS_OPTS_H +#define __KOS_OPTS_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +/** \file kos/opts.h + \brief Compile-time options regarding debugging and other topics. + + This file is meant to be a kind of Grand Central Station for all of the + various compile-time options that can be set when building KOS. Each of the + various compile-time macros that control things like additional debugging + checks and such should be documented in this particular file. In addition, + groups of related macros are provided here to make it easier to set these + options at compile time. + + Basically, this is here to make it easier to customize your copy of KOS. In + the past, you would have had to search through all the various files to find + potential options, which was both annoying and error-prone. In addition, + often various debugging flags would end up being set in the main repository + as people debugged individual pieces of code, leaving them set for everyone + else, even if they aren't necessarily useful/helpful all the time (KM_DBG, + I'm looking at you). + + \author Lawrence Sebald +*/ + +/* Various debug options. Uncomment the #define line to enable the specific + option described. */ +/* Enable debugging in fs_dclnative. This filesystem is deprecated, so there + probably won't be any good reason to enable these two. The first prints a bit + of debugging data, whereas the second prints out all packets received and + transmitted as well. You must uncomment the first in order for the second to + have any effect. */ +/* #define DCLN_DEBUG 1 */ +/* #define DCLN_DEBUG_VERBOSE 1 */ + + +/* Enable debugging in fs_vmu. */ +/* #define VMUFS_DEBUG 1 */ + + +/* Enable to allow extra debugging checks in the malloc code itself. This + sometimes catches corrupted blocks. Recommended during debugging phases. */ +/* #define MALLOC_DEBUG 1 */ + +/* Enable this define if you want costly malloc debugging (buffer sentinel + checking, block leak checking, etc). Recommended during debugging phases, but + you should probably take it out before you start your final testing. */ +/* #define KM_DBG 1 */ + +/* Enable this define if you want REALLY verbose malloc debugging (print every + time a block is allocated or freed). Only enable this if you are having some + serious issues. */ +/* #define KM_DBG_VERBOSE 1 */ + + +/* The following three macros are similar to the ones above, but for the PVR + memory pool malloc. */ +/* #define PVR_MALLOC_DEBUG 1 */ +/* #define PVR_KM_DBG 1 */ +/* #define PVR_KM_DBG_VERBOSE 1 */ + + +/* Aggregate debugging levels. It's probably best to enable these with your + KOS_CFLAGS when compiling KOS itself, but they're all documented here and + can be enabled here, if you really want to. */ + +/* Enable all recommended options for normal debugging use. This enables the + first level of malloc debugging for the main pool, as well as the internal + dlmalloc debugging code for the main pool. This is essentially the set that + was normally enabled in the repository tree. */ +/* #define KOS_DEBUG 1 */ + +/* Enable verbose debugging support. Basically, if your code is crashing and the + stuff in the first level doesn't help, then use this one instead. This adds + in verbose malloc debugging in the main pool, as well as basic PVR malloc + debugging. */ +/* #define KOS_DEBUG 2 */ + +/* Enable verbose debugging support, plus additional debugging options that + normally wouldn't be needed. Once again, try lighter levels before this one, + as there's not much reason this one should ever be needed. This level + includes the internal debugging stuff in fs_vmu, verbose debugging in the PVR + malloc, as well as everything in level 2. */ +/* #define KOS_DEBUG 3 */ + + +#if KOS_DEBUG >= 1 +#define MALLOC_DEBUG 1 +#define KM_DBG 1 +#endif + +#if KOS_DEBUG >= 2 +#define KM_DBG_VERBOSE 1 +#define PVR_MALLOC_DEBUG 1 +#define PVR_KM_DBG 1 +#endif + +#if KOS_DEBUG >= 3 +#define PVR_KM_DBG_VERBOSE 1 +#define VMUFS_DEBUG 1 +#endif + +__END_DECLS + +#endif /* !__KOS_OPTS_H */ diff --git a/kernel/arch/dreamcast/fs/fs_dclnative.c b/kernel/arch/dreamcast/fs/fs_dclnative.c index 852c32b..6a05191 100644 --- a/kernel/arch/dreamcast/fs/fs_dclnative.c +++ b/kernel/arch/dreamcast/fs/fs_dclnative.c @@ -43,9 +43,6 @@ int dcln_syscall_retval; unsigned char *dcln_syscall_data; int dcln_escape_loop; -// #define DEBUG -// #define DEBUG_VERBOSE - /* This uses an addition to dc-load-ip 1.0.3 */ typedef struct { uint32 toolip; @@ -64,7 +61,7 @@ static void get_tool_ip() { dcln_our_ip = hi.ourip; memcpy(dcln_tool_mac, hi.toolmac, 6); -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("tool = %08lx/%d, us = %08lx\n", dcln_tool_ip, dcln_tool_port, dcln_our_ip); #endif @@ -92,7 +89,7 @@ static net_input_func ni_old; static int dcln_input(netif_t * src, uint8 * pkt, int pktsize) { int idx = pkt_head; -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("received a packet\n"); #endif @@ -100,7 +97,7 @@ static int dcln_input(netif_t * src, uint8 * pkt, int pktsize) { if(pkt_cnt >= PKT_BUF_CNT) return 0; -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("storing it as index %d\n", idx); #endif @@ -120,11 +117,11 @@ static int dcln_input(netif_t * src, uint8 * pkt, int pktsize) { we don't have an output device yet, just scan for the single present device and cache it. */ void dcln_tx(uint8 * pkt, int len) { -#ifdef DEBUG +#ifdef DCLN_DEBUG int i; printf("transmitting a packet of len %d:\n", len); -#ifdef DEBUG_VERBOSE +#ifdef DCLN_DEBUG_VERBOSE for(i = 0; i < len; i++) { printf("%02x ", pkt[i]); @@ -148,14 +145,14 @@ void dcln_rx_loop() { while(!dcln_escape_loop) { /* Wait for some data to arrive */ -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("waiting for a packet\n"); #endif sem_wait(pkt_sem); -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("received a packet on slot %d w/size %d:\n", pkt_tail, pkt_sizes[pkt_tail]); -#ifdef DEBUG_VERBOSE +#ifdef DCLN_DEBUG_VERBOSE for(i = 0; i < pkt_sizes[pkt_tail]; i++) { printf("%02x ", pkt_bufs[pkt_tail][i]); @@ -448,7 +445,7 @@ int fs_dclnative_init() { netif_t * n; /* Find our output device */ -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("finding device:\n"); #endif LIST_FOREACH(n, &net_if_list, if_list) { @@ -464,7 +461,7 @@ int fs_dclnative_init() { return -1; } -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("found device at %p (%s)\n", outdev, outdev->descr); #endif @@ -494,19 +491,11 @@ int fs_dclnative_init() { /* Enable us on the networking. I have no idea why this stupid line warns without the cast. */ -#ifdef DEBUG +#ifdef DCLN_DEBUG printf("setting net target\n"); #endif ni_old = net_input_set_target((net_input_func)dcln_input); - /* Hook printk */ -//#ifndef DEBUG -//#else - thd_sleep(1000); - dclnative_printk("Test through dcl_native\n"); - dclnative_printk("switching printfs!\n"); - old_printk = dbgio_set_printk(dclnative_printk); -//#endif /* Register with VFS */ return fs_handler_add("/pc", &vh); @@ -529,4 +518,3 @@ int fs_dclnative_shutdown() { return 0; } - diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c index 4795ca5..5d57849 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c @@ -12,6 +12,8 @@ #include <malloc.h> /* For the struct mallinfo defs */ +#include <kos/opts.h> + /* This module basically serves as a KOS-friendly front end and support routines @@ -25,13 +27,6 @@ instead. ^_^; */ -/* Uncomment this line to enable leak checking */ -/* #define KM_DBG */ - -/* Uncomment this if you want REALLY verbose debugging (print - every time a block is allocated or freed) */ -/* #define KM_DBG_VERBOSE */ - /* Bring in some prototypes from pvr_mem_core.c */ /* We can't directly include its header because of name clashes with the real malloc header */ @@ -42,7 +37,7 @@ extern void pvr_int_mem_reset(); extern void pvr_int_malloc_stats(); -#ifdef KM_DBG +#ifdef PVR_KM_DBG #include <kos/thread.h> #include <arch/arch.h> @@ -58,7 +53,7 @@ typedef struct memctl { static LIST_HEAD(memctl_list, memctl) block_list; -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ /* PVR RAM base; NULL is considered invalid */ @@ -90,10 +85,10 @@ void * pvr_int_sbrk(size_t amt) { will be relative to the base of texture memory (zero-based) */ pvr_ptr_t pvr_mem_malloc(size_t size) { uint32 rv32; -#ifdef KM_DBG +#ifdef PVR_KM_DBG uint32 ra = arch_get_ret_addr(); memctl_t * ctl; -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ CHECK_MEM_BASE; @@ -101,16 +96,16 @@ pvr_ptr_t pvr_mem_malloc(size_t size) { assert_msg((rv32 & 0x1f) == 0, "dlmalloc's alignment is broken; please make a bug report"); -#ifdef KM_DBG +#ifdef PVR_KM_DBG ctl = malloc(sizeof(memctl_t)); ctl->size = size; ctl->thread = thd_current->tid; ctl->addr = ra; ctl->block = (pvr_ptr_t)rv32; LIST_INSERT_HEAD(&block_list, ctl, list); -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ -#ifdef KM_DBG_VERBOSE +#ifdef PVR_KM_DBG_VERBOSE printf("Thread %d/%08lx allocated %d bytes at %08lx\n", ctl->thread, ctl->addr, ctl->size, rv32); #endif @@ -120,20 +115,20 @@ pvr_ptr_t pvr_mem_malloc(size_t size) { /* Free a previously allocated chunk of memory */ void pvr_mem_free(pvr_ptr_t chunk) { -#ifdef KM_DBG +#ifdef PVR_KM_DBG uint32 ra = arch_get_ret_addr(); memctl_t * ctl; int found; -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ CHECK_MEM_BASE; -#ifdef KM_DBG_VERBOSE +#ifdef PVR_KM_DBG_VERBOSE printf("Thread %d/%08lx freeing block @ %08lx\n", thd_current->tid, ra, (uint32)chunk); #endif -#ifdef KM_DBG +#ifdef PVR_KM_DBG found = 0; LIST_FOREACH(ctl, &block_list, list) { @@ -150,14 +145,14 @@ void pvr_mem_free(pvr_ptr_t chunk) { (uint32)chunk, thd_current->tid, ra); } -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ pvr_int_free((void *)chunk); } /* Check the memory block list to see what's allocated */ void pvr_mem_print_list() { -#ifdef KM_DBG +#ifdef PVR_KM_DBG memctl_t * ctl; printf("pvr_mem_print_list block list:\n"); @@ -166,7 +161,7 @@ void pvr_mem_print_list() { ctl->block, ctl->size, ctl->thread, ctl->addr); } printf("pvr_mem_print_list end block list\n"); -#endif /* KM_DBG */ +#endif /* PVR_KM_DBG */ } /* Return the number of bytes available still in the memory pool */ @@ -199,8 +194,7 @@ void pvr_mem_stats() { printf("pvr_mem_stats():\n"); pvr_int_malloc_stats(); printf("max sbrk base: %08lx\n", (uint32)pvr_mem_base); -#ifdef KM_DBG +#ifdef PVR_KM_DBG pvr_mem_print_list(); #endif } - diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c b/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c index 799df1b..668ce82 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c @@ -33,6 +33,14 @@ #include "pvr_mem_core.h" +#include <kos/opts.h> + +#undef DEBUG + +#ifdef PVR_MALLOC_DEBUG +#define DEBUG 1 +#endif + /* Defined in pvr_mem.c */ extern void * pvr_int_sbrk(size_t amt); diff --git a/kernel/libc/koslib/malloc.c b/kernel/libc/koslib/malloc.c index c8eda90..50d705c 100644 --- a/kernel/libc/koslib/malloc.c +++ b/kernel/libc/koslib/malloc.c @@ -23,22 +23,16 @@ #include <arch/spinlock.h> #include <arch/arch.h> +#include <kos/opts.h> + +#undef DEBUG + +#ifdef MALLOC_DEBUG /* Enable to allow extra debugging checks in the malloc code itself. This sometimes catches corrupted blocks. Recommended during debugging phases. */ #define DEBUG 1 - -/* Enable this define if you want costly malloc debugging (buffer - sentinel checking, block leak checking, etc). Recommended during - debugging phases, but you should probably take it out before you - start your final testing. */ -#define KM_DBG - -/* Enable this define if you want REALLY verbose debugging (print - every time a block is allocated or freed). Only enable this if you - are having some serious issues. */ -// #define KM_DBG_VERBOSE - +#endif /* KOS specific things */ #define USE_MALLOC_LOCK @@ -1862,6 +1856,7 @@ int mem_check_block(Void_t* m) { return retv; #else + (void)m; return 0; #endif } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-09-02 19:21:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 65aa964a53ae91d82ca50d3937fff95fe675bbd8 (commit) from 138e90c57268f886ab6d1d84c299825358715786 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 65aa964a53ae91d82ca50d3937fff95fe675bbd8 Author: Lawrence Sebald <ljs...@us...> Date: Tue Sep 2 15:20:09 2014 -0400 Remove the ENABLE_WRITES macro from flashrom.c. I can't think of any good reason to keep this around, as it should be pretty obvious that a function called flashrom_write() or flashrom_delete() is going to write to the flashrom. So, the macro has been removed and the default state is now just as if the macro was defined. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/flashrom.c | 17 ----------------- 1 files changed, 0 insertions(+), 17 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/flashrom.c b/kernel/arch/dreamcast/hardware/flashrom.c index d8fb2fd..b76749b 100644 --- a/kernel/arch/dreamcast/hardware/flashrom.c +++ b/kernel/arch/dreamcast/hardware/flashrom.c @@ -22,11 +22,6 @@ #include <dc/flashrom.h> #include <arch/irq.h> -/* This is the fateful define. Re-enable this at the peril of your - Dreamcast's soul ;) */ -/* #define ENABLE_WRITES 1 */ - - /* First, implementation of the syscall wrappers. */ typedef int (*flashrom_sc)(int, void *, int, int); @@ -55,7 +50,6 @@ int flashrom_read(int offset, void * buffer_out, int bytes) { } int flashrom_write(int offset, void * buffer, int bytes) { -#ifdef ENABLE_WRITES flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); int old, rv; @@ -63,16 +57,9 @@ int flashrom_write(int offset, void * buffer, int bytes) { rv = sc(offset, buffer, bytes, 2); irq_restore(old); return rv; -#else - (void)offset; - (void)buffer; - (void)bytes; - return -1; -#endif } int flashrom_delete(int offset) { -#ifdef ENABLE_WRITES flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); int old, rv; @@ -80,10 +67,6 @@ int flashrom_delete(int offset) { rv = sc(offset, 0, 0, 3); irq_restore(old); return rv; -#else - (void)offset; - return -1; -#endif } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-09-02 14:46:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 138e90c57268f886ab6d1d84c299825358715786 (commit) via cba41c1e91812e686579937ca761783af409777e (commit) via 5e6396702c1ecdea98ce30c24c39af7c1da2f8de (commit) from 22c6d1df7ac699d365a8cbff548477e44c9d1461 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 138e90c57268f886ab6d1d84c299825358715786 Author: Lawrence Sebald <ljs...@us...> Date: Tue Sep 2 10:45:10 2014 -0400 Add a parameter to the pvr_init_params_t structure to disable translucent autosort, as well as a function to do on a frame-by-frame basis. commit cba41c1e91812e686579937ca761783af409777e Author: Lawrence Sebald <ljs...@us...> Date: Tue Sep 2 10:41:45 2014 -0400 Clean up the flashrom syscall definitions to match the way the other bios syscalls in init.c are handled. commit 5e6396702c1ecdea98ce30c24c39af7c1da2f8de Author: Lawrence Sebald <ljs...@us...> Date: Tue Sep 2 09:52:10 2014 -0400 Fix the header guard on vq_internal.h in utils/vqenc. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/flashrom.c | 14 +++------ kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c | 17 +++++++----- .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 9 +++--- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 8 +---- kernel/arch/dreamcast/include/dc/pvr.h | 28 +++++++++++++++++++- utils/vqenc/vq_internal.h | 2 +- 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/flashrom.c b/kernel/arch/dreamcast/hardware/flashrom.c index 49b4fb4..d8fb2fd 100644 --- a/kernel/arch/dreamcast/hardware/flashrom.c +++ b/kernel/arch/dreamcast/hardware/flashrom.c @@ -28,14 +28,13 @@ /* First, implementation of the syscall wrappers. */ +typedef int (*flashrom_sc)(int, void *, int, int); int flashrom_info(int part, int * start_out, int * size_out) { - int (*sc)(int, uint32*, int, int); + flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); uint32 ptrs[2]; int rv; - *((uint32 *)&sc) = *((uint32 *)0x8c0000b8); - if(sc(part, ptrs, 0, 0) == 0) { *start_out = ptrs[0]; *size_out = ptrs[1]; @@ -48,21 +47,19 @@ int flashrom_info(int part, int * start_out, int * size_out) { } int flashrom_read(int offset, void * buffer_out, int bytes) { - int (*sc)(int, void*, int, int); + flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); int rv; - *((uint32 *)&sc) = *((uint32 *)0x8c0000b8); rv = sc(offset, buffer_out, bytes, 1); return rv; } int flashrom_write(int offset, void * buffer, int bytes) { #ifdef ENABLE_WRITES - int (*sc)(int, void*, int, int); + flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); int old, rv; old = irq_disable(); - *((uint32 *)&sc) = *((uint32 *)0x8c0000b8); rv = sc(offset, buffer, bytes, 2); irq_restore(old); return rv; @@ -76,11 +73,10 @@ int flashrom_write(int offset, void * buffer, int bytes) { int flashrom_delete(int offset) { #ifdef ENABLE_WRITES - int (*sc)(int, int, int, int); + flashrom_sc sc = (flashrom_sc)(*((uint32 *)0x8c0000b8)); int old, rv; old = irq_disable(); - *((uint32 *)&sc) = *((uint32 *)0x8c0000b8); rv = sc(offset, 0, 0, 3); irq_restore(old); return rv; diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c b/kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c index 5facd9d..3730493 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_buffers.c @@ -1,7 +1,8 @@ /* KallistiOS ##version## pvr_buffers.c - Copyright (C)2002,2004 Dan Potter + Copyright (C) 2002, 2004 Dan Potter + Copyright (C) 2014 Lawrence Sebald */ @@ -22,7 +23,7 @@ /* Fill Tile Matrix buffers. This function takes a base address and sets up the rendering structures there. Each tile of the screen (32x32) receives a small buffer space. */ -void pvr_init_tile_matrix(int which) { +static void pvr_init_tile_matrix(int which, int presort) { volatile pvr_ta_buffers_t *buf; int x, y; uint32 *vr; @@ -66,7 +67,7 @@ void pvr_init_tile_matrix(int which) { for(x = 0; x < pvr_state.tw; x++) { for(y = 0; y < pvr_state.th; y++) { /* Control word */ - vr[0] = (y << 8) | (x << 2); + vr[0] = (y << 8) | (x << 2) | (presort << 29); /* Opaque poly buffer */ vr[1] = buf->opb_type[0] + opbs[0] * pvr_state.tw * y + opbs[0] * x; @@ -93,11 +94,15 @@ void pvr_init_tile_matrix(int which) { } /* Fill all tile matrices */ -void pvr_init_tile_matrices() { +void pvr_init_tile_matrices(int presort) { int i; for(i = 0; i < 2; i++) - pvr_init_tile_matrix(i); + pvr_init_tile_matrix(i, presort); +} + +void pvr_set_presort_mode(int presort) { + pvr_init_tile_matrix(pvr_state.ta_target, presort); } @@ -286,5 +291,3 @@ void pvr_allocate_buffers(pvr_init_params_t *params) { 0x800000 - pvr_state.texture_base); #endif /* !NDEBUG */ } - - diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c index 7023426..6bbeb60 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## pvr_init_shutdown.c - Copyright (C)2002,2004 Dan Potter + Copyright (C) 2002, 2004 Dan Potter */ @@ -36,6 +36,9 @@ int pvr_init_defaults() { 0, /* No FSAA */ + 0, + + /* Translucent Autosort enabled. */ 0 }; @@ -87,7 +90,7 @@ int pvr_init(pvr_init_params_t *params) { pvr_allocate_buffers(params); // Initialize tile matrices - pvr_init_tile_matrices(); + pvr_init_tile_matrices(!!params->autosort_disabled); // Setup all pipeline targets. Yes, this is redundant. :) I just // like to have it explicit. @@ -238,5 +241,3 @@ int pvr_shutdown() { /* Return success */ return 0; } - - diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h index d3bf98b..bd5e041 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h @@ -1,7 +1,7 @@ /* KallistiOS ##version## pvr_internal.h - Copyright (C)2002,2003,2004 Dan Potter + Copyright (C) 2002, 2003, 2004 Dan Potter */ @@ -251,11 +251,8 @@ typedef struct pvr_bkg_poly { /* Initialize buffers for TA/ISP/TSP usage */ void pvr_allocate_buffers(pvr_init_params_t *params); -/* Fill in a single tile matrix (used by pvr_init_tile_matrices) */ -void pvr_init_tile_matrix(int which); - /* Fill the tile matrices (after it's initialized) */ -void pvr_init_tile_matrices(); +void pvr_init_tile_matrices(int presort); /**** pvr_misc.c ******************************************************/ @@ -297,4 +294,3 @@ void pvr_int_handler(uint32 code); #endif - diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index f404d7a..d1ea601 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -2,10 +2,11 @@ dc/pvr.h Copyright (C) 2002 Dan Potter + Copyright (C) 2014 Lawrence Sebald Low-level PVR 3D interface for the DC Note: this API does _not_ handle any sort of transformations - (including perspective!) so for that, you should look to KGL. + (including perspective!) so for that, you should look to KGL. */ /** \file dc/pvr.h @@ -1076,6 +1077,15 @@ typedef struct { setting and stretching your image to double the native screen width, you can get horizontal full-screen anti-aliasing. */ int fsaa_enabled; + + /** \brief Disable translucent polygon autosort? + + Set to non-zero to disable translucent polygon autosorting. By enabling + this setting, the PVR acts more like a traditional Z-buffered system + when rendering translucent polygons, meaning you must pre-sort them + yourself if you want them to appear in the right order. */ + int autosort_disabled; + } pvr_init_params_t; /** \brief Initialize the PVR chip to ready status. @@ -1442,6 +1452,22 @@ void * pvr_vertbuf_tail(pvr_list_t list); */ void pvr_vertbuf_written(pvr_list_t list, uint32 amt); +/** \brief Set the translucent polygon sort mode for the next frame. + + This function sets the translucent polygon sort mode for the next frame of + output, potentially switching between autosort and presort mode. + + For most programs, you'll probably want to set this at initialization time + (with the autosort_disabled field in the pvr_init_params_t structure) and + not mess with it per-frame. It is recommended that if you do use this + function to change the mode that you should set it each frame to ensure that + the mode is set properly. + + \param presort Set to 1 to set the presort mode for translucent + polygons, set to 0 to use autosort mode. +*/ +void pvr_set_presort_mode(int presort); + /** \brief Begin collecting data for a frame of 3D output to the off-screen frame buffer. diff --git a/utils/vqenc/vq_internal.h b/utils/vqenc/vq_internal.h index d0f8b6d..d633b1d 100644 --- a/utils/vqenc/vq_internal.h +++ b/utils/vqenc/vq_internal.h @@ -1,6 +1,6 @@ #ifndef __VQ_INTERNAL_H -#define __VQ_INTENRAL_H +#define __VQ_INTERNAL_H #include "vq_types.h" hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-08-30 17:43:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 22c6d1df7ac699d365a8cbff548477e44c9d1461 (commit) via 45028d08c048c57e3ea54b5a06cb52a5f9079055 (commit) from 98c43f8bd0680cc65408acf43871f2b29f6285d3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 22c6d1df7ac699d365a8cbff548477e44c9d1461 Merge: 45028d0 98c43f8 Author: Lawrence Sebald <ljs...@us...> Date: Sat Aug 30 13:42:50 2014 -0400 Merge branch 'master' of ssh://git.code.sf.net/p/cadcdev/kallistios commit 45028d08c048c57e3ea54b5a06cb52a5f9079055 Author: Lawrence Sebald <ljs...@us...> Date: Sat Aug 30 13:41:43 2014 -0400 Remove Josh Pearson's nickname from the AUTHORS list. ----------------------------------------------------------------------- Summary of changes: AUTHORS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/AUTHORS b/AUTHORS index ee8140c..01d6036 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,7 +38,7 @@ Vincent Penne: 2004 Roger Cattermole: 2002 Paul Boese: 2002 Brian Paul: 1999, 2000, 2001 -Josh "PH3NOM" Pearson: 2013, 2014 +Josh Pearson: 2013, 2014 Files with Specific licenses: ----------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-08-30 17:33:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 092a04cccfa14f305188edc653ebd511630463ae (commit) from be969bd840b9623640c5d9992034a8b5db4e3c01 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 092a04cccfa14f305188edc653ebd511630463ae Author: Lawrence Sebald <ljs...@us...> Date: Sat Aug 30 13:33:02 2014 -0400 Ignore the noise... Just testing something. ----------------------------------------------------------------------- Summary of changes: .gitattributes | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3c15981..de7e20c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,6 @@ * text=auto + +# Set .c, .h, .cnf, and Makefiles to all be text. *.c text *.h text Makefile text hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Lawrence S. <ljs...@us...> - 2014-08-29 19:58:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 47d297747864df3d4546683a36e811e278471515 (commit) from 8572f92b6a8190e39795b9ebb02dc0f6dd23db21 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 47d297747864df3d4546683a36e811e278471515 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 29 15:58:17 2014 -0400 Update libgl to commit be969b. ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 61b809f..be969bd 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 61b809f5cd7bce8f2dec2f40da510551daffc6f0 +Subproject commit be969bd840b9623640c5d9992034a8b5db4e3c01 hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: Lawrence S. <ljs...@us...> - 2014-08-29 19:57:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via be969bd840b9623640c5d9992034a8b5db4e3c01 (commit) via 5daf045d0c82ea7998917f23a7ffb068b81feb85 (commit) from 61b809f5cd7bce8f2dec2f40da510551daffc6f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit be969bd840b9623640c5d9992034a8b5db4e3c01 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 29 15:56:23 2014 -0400 Normalize line endings in libgl to LF rather than CRLF. commit 5daf045d0c82ea7998917f23a7ffb068b81feb85 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 29 15:53:39 2014 -0400 Add .gitattributes file for setting line endings... ----------------------------------------------------------------------- Summary of changes: .gitattributes | 5 + gl-api.c | 2764 ++++++++++++++++++++++++++++---------------------------- gl-api.h | 232 +++--- gl-arrays.c | 2076 +++++++++++++++++++++--------------------- gl-arrays.h | 116 ++-- gl-clip.c | 1490 +++++++++++++++--------------- gl-clip.h | 88 +- gl-fog.c | 204 +++--- gl-light.c | 1124 ++++++++++++------------ gl-light.h | 102 +- gl-matrix.c | 806 +++++++++--------- gl-pvr.c | 430 +++++----- gl-pvr.h | 108 ++-- gl-rgb.c | 232 +++--- gl-rgb.h | 126 ++-- gl-sh4-light.S | 464 +++++----- gl-sh4.h | 104 ++-- include/gl.h | 1054 +++++++++++----------- include/glu.h | 90 +- include/glut.h | 60 +- 20 files changed, 5840 insertions(+), 5835 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3c15981 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +* text=auto +*.c text +*.h text +Makefile text +*.cnf text diff --git a/gl-api.c b/gl-api.c index c1f3313..a53aacd 100755 --- a/gl-api.c +++ b/gl-api.c @@ -1,1382 +1,1382 @@ -/* KallistiGL for KallistiOS ##version## - - libgl/gl-api.c - Copyright (C) 2013-2014 Josh "PH3NOM" Pearson - Copyright (C) 2014 Lawrence Sebald - - Some functionality adapted from the original KOS libgl: - Copyright (C) 2001 Dan Potter - Copyright (C) 2002 Benoit Miller - - This API implements much but not all of the OpenGL 1.1 for KallistiOS. -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "gl.h" -#include "glu.h" -#include "gl-api.h" -#include "gl-sh4.h" -#include "gl-pvr.h" - -/* Texture Submission Functions ************************************************************************/ -/* The texutre sumbission uses a fixed-size buffer, that defaults to 1024 textures. - That means that you must manage your texture submission by calling glDelTextures(...) - when you are done using a texture that was created by glGenTextures(...). - The size of the texture buffer can be controlled by setting GL_MAX_TEXTURES on gl-pvr.h. - - glTexImage2D(..) is used for loading texture data to OpenGL that is located in Main RAM: - OpenGL will allocate VRAM for the texture, and copy the texture data from Main RAM to VRAM. - - glKosTexImage2D(...) is used for loading texture data to OpenGL that is already in VRAM: - This mode must be used for a render-to-texture if you are using glutSwapBuffersToTexture(). -*/ - -typedef struct { - GLenum target; - GLint level; - GLint border; - GLenum format; - GLenum type; - GLint filter, env; - GLuint width, height; - GLuint internalFormat; - GLvoid *data; -} glTexCxt; - -static glTexCxt GL_TEX_LIST[GL_MAX_TEXTURES]; -static GLint GL_BOUND_TEX = -1, GL_LAST_BOUND_TEX = -1, - GL_BOUND_TEX1 = -1, GL_LAST_BOUND_TEX1 = -1; - -static GLubyte BLEND_SRC = PVR_BLEND_ONE; -static GLubyte BLEND_DST = PVR_BLEND_ZERO; - -static GLubyte GL_SHADE_FUNC = PVR_SHADE_GOURAUD; - -static GLubyte GL_CULL_FUNC = PVR_CULLING_NONE; - -static GLubyte GL_DEPTH_CMP = PVR_DEPTHCMP_GEQUAL; -static GLubyte GL_DEPTH_ENABLE = PVR_DEPTHWRITE_ENABLE; - -static GLubyte GL_TEX_ENV = PVR_TXRENV_MODULATEALPHA; - -static GLubyte GL_ENABLE_CLIPZ = 0; -static GLubyte GL_ENABLE_LIGHTING = 0; -static GLubyte GL_ENABLE_SCISSOR = 0; -static GLubyte GL_ENABLE_FOG = 0; -static GLubyte GL_ENABLE_CULLING = 0; -static GLubyte GL_ENABLE_DEPTH_TEST = 0; -static GLubyte GL_ENABLE_SUPERSAMP = 0; - -static GLubyte GL_FACE_FRONT = 0; -static GLubyte GL_CLAMP_ST = 0; - -/* Primitive 3D Position Submission */ -void (*glVertex3f)(float, float, float); -void (*glVertex3fv)(float *); - -#define GL_CLAMP_U 0x0F -#define GL_CLAMP_V 0xF0 -#define GL_CLAMP_UV 0xFF - -#define GL_TEXTURE_0 1<<0 -#define GL_TEXTURE_1 1<<1 - -static GLuint GL_TEXTURE_ENABLED = 0; -static GLuint GL_CUR_ACTIVE_TEX = 0; - -void glActiveTexture(GLenum texture) { - if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + GL_MAX_TEXTURE_UNITS) - return; - - GL_CUR_ACTIVE_TEX = ((texture & 0xFF) - (GL_TEXTURE0 & 0xFF)); -} - -void glBindTexture(GLenum target, GLuint texture) { - if(target == GL_TEXTURE_2D) { - switch(GL_CUR_ACTIVE_TEX) { - case 0: - GL_BOUND_TEX = texture; - GL_LAST_BOUND_TEX = GL_BOUND_TEX; - break; - - case 1: - GL_BOUND_TEX1 = texture; - GL_LAST_BOUND_TEX1 = GL_BOUND_TEX1; - break; - } - } -} - -void glGetIntegerv(GLenum pname, GLint *params) { - switch(pname) { - case GL_ACTIVE_TEXTURE: - *params = GL_CUR_ACTIVE_TEX; - break; - - case GL_BLEND: - *params = _glKosList(); - break; - - case GL_BLEND_DST: - *params = BLEND_SRC; - break; - - case GL_BLEND_SRC: - *params = BLEND_DST; - break; - - case GL_CULL_FACE: - *params = GL_ENABLE_CULLING; - break; - - case GL_CULL_FACE_MODE: - *params = GL_CULL_FUNC; - break; - - case GL_DEPTH_FUNC: - *params = GL_DEPTH_CMP; - break; - - case GL_DEPTH_TEST: - *params = GL_ENABLE_DEPTH_TEST; - break; - - case GL_DEPTH_WRITEMASK: - *params = GL_DEPTH_ENABLE; - break; - - case GL_FRONT_FACE: - *params = GL_FACE_FRONT; - break; - - case GL_SCISSOR_TEST: - *params = GL_ENABLE_SCISSOR; - break; - - default: - *params = -1; // Indicate invalid parameter // - break; - } -} - -void glGetFloatv(GLenum pname, GLfloat *params) { - switch(pname) { - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - glKosGetMatrix(pname - GL_MODELVIEW_MATRIX + 1, params); - break; - - default: - *params = (GLfloat)GL_INVALID_ENUM; - break; - } -} - -static void _glKosInitTextures() { - GLuint i; - - for(i = 0; i < GL_MAX_TEXTURES; i++) - GL_TEX_LIST[i].data = NULL; -} - -static GLuint _glKosNextTexture() { - GLint i; - - for(i = 0; i < GL_MAX_TEXTURES; i++) - if(GL_TEX_LIST[i].data == NULL) - return i; - - return 0; /* Invalid Texture! */ -} - -GLuint glKosMipMapTexSize(GLuint width, GLuint height) { - GLuint b = 0; - - while(width >= 1 && height >= 1) { - b += width * height * 2; - - if(width >= 1) - width /= 2; - - if(height >= 1) - height /= 2; - } - - return b; -} - -void glGenTextures(GLsizei n, GLuint *textures) { - while(n--) - *textures++ = _glKosNextTexture(); -} - -void glDelTextures(GLsizei n, GLuint *textures) { - while(n--) { - if(GL_TEX_LIST[*textures].data != NULL) { - pvr_mem_free(GL_TEX_LIST[*textures].data); - GL_TEX_LIST[*textures].data = NULL; - } - - textures++; - } -} - -void glTexImage2D(GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, GLvoid *data) { - if(target != GL_TEXTURE_2D) return; - - GL_TEX_LIST[GL_BOUND_TEX].target = target; - GL_TEX_LIST[GL_BOUND_TEX].level = level; - GL_TEX_LIST[GL_BOUND_TEX].border = border; - GL_TEX_LIST[GL_BOUND_TEX].format = format; - GL_TEX_LIST[GL_BOUND_TEX].type = type; - - GLuint bytes; - - if(!level) - bytes = width * height * 2; - else - bytes = glKosMipMapTexSize(width, height); - - if(format == PVR_TXRFMT_VQ_ENABLE) - bytes /= 4; - - GL_TEX_LIST[GL_BOUND_TEX].data = pvr_mem_malloc(bytes); - - GL_TEX_LIST[GL_BOUND_TEX].width = width; - GL_TEX_LIST[GL_BOUND_TEX].height = height; - GL_TEX_LIST[GL_BOUND_TEX].internalFormat = internalFormat; - - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; - - sq_cpy(GL_TEX_LIST[GL_BOUND_TEX].data, data, bytes); -} - -void glKosTexImage2D(GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, GLvoid *data) { - if(target != GL_TEXTURE_2D) return; - - GL_TEX_LIST[GL_BOUND_TEX].target = target; - GL_TEX_LIST[GL_BOUND_TEX].level = level; - GL_TEX_LIST[GL_BOUND_TEX].border = border; - GL_TEX_LIST[GL_BOUND_TEX].format = format; - GL_TEX_LIST[GL_BOUND_TEX].type = type; - - GL_TEX_LIST[GL_BOUND_TEX].data = data; - - GL_TEX_LIST[GL_BOUND_TEX].width = width; - GL_TEX_LIST[GL_BOUND_TEX].height = height; - GL_TEX_LIST[GL_BOUND_TEX].internalFormat = internalFormat; - - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; -} - -void glTexParameteri(GLenum target, GLenum pname, GLint param) { - if(target == GL_TEXTURE_2D) { - switch(pname) { - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_MIN_FILTER: - switch(param) { - case GL_LINEAR: - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_BILINEAR; - break; - - case GL_NEAREST: - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NEAREST; - break; - - case GL_FILTER_NONE: /* Compatabile with deprecated kgl */ - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; - break; - - case GL_FILTER_BILINEAR: /* Compatabile with deprecated kgl */ - GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_BILINEAR; - break; - - case GL_NEAREST_MIPMAP_NEAREST: - GL_TEX_LIST[GL_BOUND_TEX].level = PVR_MIPMAP_ENABLE; - break; - - default: - break; - } - - break; - - case GL_TEXTURE_WRAP_S: - switch(param) { - case GL_CLAMP: - GL_CLAMP_ST |= GL_CLAMP_U; - break; - - case GL_REPEAT: - GL_CLAMP_ST ^= GL_CLAMP_U; - break; - } - - break; - - case GL_TEXTURE_WRAP_T: - switch(param) { - case GL_CLAMP: - GL_CLAMP_ST |= GL_CLAMP_V; - break; - - case GL_REPEAT: - GL_CLAMP_ST ^= GL_CLAMP_V; - break; - } - - break; - } - } -} - -void glTexEnvi(GLenum target, GLenum pname, GLint param) { - if(target == GL_TEXTURE_ENV) - if(pname == GL_TEXTURE_ENV_MODE) - if(param >= PVR_TXRENV_REPLACE && param <= PVR_TXRENV_MODULATEALPHA) - GL_TEX_ENV = param; -} - -void glTexEnvf(GLenum target, GLenum pname, GLfloat param) { - /* GL_TEXTURE_LOD_BIAS Not Implemented */ - glTexEnvi(target, pname, param); -} - -GLint gluBuild2DBiMipmaps(GLenum target, GLint internalFormat, GLsizei width, - GLsizei height, GLenum format, GLenum type, const void *data) { - if(target != GL_TEXTURE_2D) - return -1; - - if(width < 1 || height < 1) - return 0; - - uint32 i = 0; - uint16 x , y; - - uint16 *src = (uint16 *)data; - uint16 *dst = (uint16 *)data + (width * height); - - for(y = 0; y < height; y += 2) { - for(x = 0; x < width; x += 2) { - switch(type) { - case GL_UNSIGNED_SHORT_5_6_5: - dst[i++] = __glKosAverageBiPixelRGB565(*src, *(src + 1)); - break; - - case GL_UNSIGNED_SHORT_4_4_4_4: - dst[i++] = __glKosAverageBiPixelARGB4444(*src, *(src + 1)); - break; - - case GL_UNSIGNED_SHORT_1_5_5_5: - dst[i++] = __glKosAverageBiPixelARGB1555(*src, *(src + 1)); - break; - } - - src += 2; - } - - src += width; - } - - return gluBuild2DBiMipmaps(target, internalFormat, width / 2, height / 2, - format, type, (uint16 *)data + (width * height)); -} - -GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, - GLsizei height, GLenum format, GLenum type, const void *data) { - if(target != GL_TEXTURE_2D) - return -1; - - if(width < 1 || height < 1) - return 0; - - if(width == 1 || height == 1) - return gluBuild2DBiMipmaps(target, internalFormat, width, height, format, type, data); - - uint32 i = 0; - uint16 x, y; - - uint16 *src = (uint16 *)data; - uint16 *dst = (uint16 *)data + (width * height); - - for(y = 0; y < height; y += 2) { - for(x = 0; x < width; x += 2) { - switch(type) { - case GL_UNSIGNED_SHORT_5_6_5: - dst[i++] = __glKosAverageQuadPixelRGB565(*src, *(src + 1), *(src + width), *(src + width + 1)); - break; - - case GL_UNSIGNED_SHORT_4_4_4_4: - dst[i++] = __glKosAverageQuadPixelARGB4444(*src, *(src + 1), *(src + width), *(src + width + 1)); - break; - - case GL_UNSIGNED_SHORT_1_5_5_5: - dst[i++] = __glKosAverageQuadPixelARGB1555(*src, *(src + 1), *(src + width), *(src + width + 1)); - break; - } - - src += 2; - } - - src += width; - } - - return gluBuild2DMipmaps(target, internalFormat, width / 2, height / 2, - format, type, (uint16 *)data + (width * height)); -} - -/* Blending / Shading functions ********************************************************/ - -void glShadeModel(GLenum mode) { - switch(mode) { - case GL_FLAT: - GL_SHADE_FUNC = PVR_SHADE_FLAT; - break; - - case GL_SMOOTH: - GL_SHADE_FUNC = PVR_SHADE_GOURAUD; - break; - } -} - -void glBlendFunc(GLenum sfactor, GLenum dfactor) { - switch(sfactor) { - case GL_ONE: - BLEND_SRC = PVR_BLEND_ONE; - break; - - case GL_ZERO: - BLEND_SRC = PVR_BLEND_ZERO; - break; - - case GL_SRC_COLOR: - BLEND_SRC = PVR_BLEND_SRCALPHA; - break; - - case GL_DST_COLOR: - BLEND_SRC = PVR_BLEND_DESTCOLOR; - break; - - case GL_SRC_ALPHA: - BLEND_SRC = PVR_BLEND_SRCALPHA; - break; - - case GL_DST_ALPHA: - BLEND_SRC = PVR_BLEND_DESTALPHA; ...<truncated>... hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Lawrence S. <ljs...@us...> - 2014-08-29 19:42:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 8572f92b6a8190e39795b9ebb02dc0f6dd23db21 (commit) from fe09e459b4875fdef1663e759af28971bd47b742 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8572f92b6a8190e39795b9ebb02dc0f6dd23db21 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 29 15:41:52 2014 -0400 Point libgl to commit 61b809. ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 0711f10..61b809f 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 0711f10b1f896beba0d9d0105399eb9a5069612a +Subproject commit 61b809f5cd7bce8f2dec2f40da510551daffc6f0 hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: Lawrence S. <ljs...@us...> - 2014-08-29 19:40:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 61b809f5cd7bce8f2dec2f40da510551daffc6f0 (commit) from 0711f10b1f896beba0d9d0105399eb9a5069612a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 61b809f5cd7bce8f2dec2f40da510551daffc6f0 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 29 15:38:42 2014 -0400 Add glGetFloatv() for reading matrices as requested in #dreamcastdev on IRC. This commit also adds a new glKosGetMatrix() function that does the same thing, but isn't limited to the modelview, projection, and texture matrices, as glGetFloatv() is. ----------------------------------------------------------------------- Summary of changes: gl-api.c | 17 ++++++++++++++++- gl-matrix.c | 8 ++++++++ include/gl.h | 8 ++++++++ 3 files changed, 32 insertions(+), 1 deletions(-) diff --git a/gl-api.c b/gl-api.c index 2577e16..c1f3313 100755 --- a/gl-api.c +++ b/gl-api.c @@ -1,7 +1,8 @@ /* KallistiGL for KallistiOS ##version## - libgl/gl.h + libgl/gl-api.c Copyright (C) 2013-2014 Josh "PH3NOM" Pearson + Copyright (C) 2014 Lawrence Sebald Some functionality adapted from the original KOS libgl: Copyright (C) 2001 Dan Potter @@ -161,6 +162,20 @@ void glGetIntegerv(GLenum pname, GLint *params) { } } +void glGetFloatv(GLenum pname, GLfloat *params) { + switch(pname) { + case GL_MODELVIEW_MATRIX: + case GL_PROJECTION_MATRIX: + case GL_TEXTURE_MATRIX: + glKosGetMatrix(pname - GL_MODELVIEW_MATRIX + 1, params); + break; + + default: + *params = (GLfloat)GL_INVALID_ENUM; + break; + } +} + static void _glKosInitTextures() { GLuint i; diff --git a/gl-matrix.c b/gl-matrix.c index 383ff91..f49731e 100755 --- a/gl-matrix.c +++ b/gl-matrix.c @@ -2,6 +2,7 @@ libgl/gl-matrix.c Copyright (C) 2013-2014 Josh "PH3NOM" Pearson + Copyright (C) 2014 Lawrence Sebald Some functionality adapted from the original KOS libgl: Copyright (C) 2001 Dan Potter @@ -393,3 +394,10 @@ void _glKosInitMatrix() { glDepthRange(0.0f, 1.0f); glViewport(0, 0, vid_mode->width, vid_mode->height); } + +void glKosGetMatrix(GLenum mode, GLfloat *params) { + if(mode < GL_SCREENVIEW || mode > GL_RENDER) + *params = (GLfloat)GL_INVALID_ENUM; + + memcpy(params, Matrix + mode, sizeof(GLfloat) * 16); +} diff --git a/include/gl.h b/include/gl.h index b56d857..f6737a1 100755 --- a/include/gl.h +++ b/include/gl.h @@ -2,6 +2,7 @@ libgl/gl.h Copyright (C) 2013-2014 Josh "PH3NOM" Pearson + Copyright (C) 2014 Lawrence Sebald Some functionality adapted from the original KOS libgl: Copyright (C) 2001 Dan Potter @@ -63,6 +64,10 @@ __BEGIN_DECLS #define GL_RENDER 0x05 #define GL_MATRIX_COUNT 0x06 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 + /* Depth buffer */ #define GL_NEVER 0x0200 #define GL_LESS 0x0201 @@ -478,6 +483,8 @@ GLAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glKosGetMatrix(GLenum mode, GLfloat *params); + /* Fog Functions - client must enable GL_FOG for this to take effect */ GLAPI void APIENTRY glFogi(GLenum pname, GLint param); @@ -506,6 +513,7 @@ GLAPI GLuint APIENTRY glKosMipMapTexSize(GLuint width, GLuint height); /* glGet Functions */ void glGetIntegerv(GLenum pname, GLint *params); +void glGetFloatv(GLenum pname, GLfloat *params); /* Multi-Texture Extensions */ GLAPI void APIENTRY glActiveTexture(GLenum texture); hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-08-27 01:19:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via fe09e459b4875fdef1663e759af28971bd47b742 (commit) from 9c430c9f25dd3706926e7678a405466ef9292c54 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fe09e459b4875fdef1663e759af28971bd47b742 Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Tue Aug 26 18:18:45 2014 -0700 #Updates related to glVertex2f functionality ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 4390d62..0711f10 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 4390d627bf25dbda727ee2c91c1db59d5a0e1e23 +Subproject commit 0711f10b1f896beba0d9d0105399eb9a5069612a hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-08-27 01:12:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 0711f10b1f896beba0d9d0105399eb9a5069612a (commit) from 4390d627bf25dbda727ee2c91c1db59d5a0e1e23 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0711f10b1f896beba0d9d0105399eb9a5069612a Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Tue Aug 26 18:11:41 2014 -0700 #Fixed glVertex2f to perform as the standard defines. glKosVertex2f is added for direct submission to PVR of 2D vertices with no transform. ----------------------------------------------------------------------- Summary of changes: gl-api.c | 19 ++++++++++--------- include/gl.h | 8 ++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gl-api.c b/gl-api.c index d2b0be2..2577e16 100755 --- a/gl-api.c +++ b/gl-api.c @@ -72,10 +72,6 @@ static GLubyte GL_ENABLE_SUPERSAMP = 0; static GLubyte GL_FACE_FRONT = 0; static GLubyte GL_CLAMP_ST = 0; -/* Primitive 2D Position Submission */ -void (*glVertex2f)(float, float); -void (*glVertex2fv)(float *); - /* Primitive 3D Position Submission */ void (*glVertex3f)(float, float, float); void (*glVertex3fv)(float *); @@ -1038,9 +1034,6 @@ void glBegin(unsigned int mode) { glVertex3f = _glKosVertex3ft; glVertex3fv = _glKosVertex3ftv; } - - glVertex2f = _glKosVertex2ft; - glVertex2fv = _glKosVertex2ftv; } void _glKosTransformClipBuf(pvr_vertex_t *v, GLuint verts) { @@ -1133,7 +1126,15 @@ void glEnd() { } } -void _glKosVertex2ft(float x, float y) { +void glVertex2f(GLfloat x, GLfloat y) { + return _glKosVertex3ft(x, y, 0.0f); +} + +void glVertex2fv(GLfloat *xy) { + return _glKosVertex3ft(xy[0], xy[1], 0.0f); +} + +void glKosVertex2f(GLfloat x, GLfloat y) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = x; @@ -1149,7 +1150,7 @@ void _glKosVertex2ft(float x, float y) { ++GL_VERTICES; } -void _glKosVertex2ftv(float *xy) { +void glKosVertex2fv(GLfloat *xy) { pvr_vertex_t *v = _glKosVertexBufPointer(); v->x = xy[0]; diff --git a/include/gl.h b/include/gl.h index b97b4d8..b56d857 100755 --- a/include/gl.h +++ b/include/gl.h @@ -352,8 +352,12 @@ GLAPI void APIENTRY glNormal3f(float x, float y, float z); GLAPI void APIENTRY glNormal3fv(float *xyz); /* Primitive 2D Position Submission */ -GLAPI void APIENTRY(*glVertex2f)(float, float); -GLAPI void APIENTRY(*glVertex2fv)(float *); +GLAPI void APIENTRY glVertex2f(GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertex2fv(GLfloat *xy); + +/* Non-Standard KOS Primitive 2D Submission. This will perform no tranformations on the vertices. */ +GLAPI void APIENTRY glKosVertex2f(GLfloat x, GLfloat y); +GLAPI void APIENTRY glKosVertex2fv(GLfloat *xy); /* Primitive 3D Position Submission */ GLAPI void APIENTRY(*glVertex3f)(float, float, float); hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Lawrence S. <ljs...@us...> - 2014-08-18 23:22:20
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 9c430c9f25dd3706926e7678a405466ef9292c54 (commit) from 05fde8a4b072051b2348c77d366f6f6296a855d0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9c430c9f25dd3706926e7678a405466ef9292c54 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 18 19:21:57 2014 -0400 Update libgl reference. ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index 9dde472..4390d62 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit 9dde4722939f8e1192291a545ad98bd138e70bf7 +Subproject commit 4390d627bf25dbda727ee2c91c1db59d5a0e1e23 hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: Lawrence S. <ljs...@us...> - 2014-08-18 23:19:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 4390d627bf25dbda727ee2c91c1db59d5a0e1e23 (commit) from 9dde4722939f8e1192291a545ad98bd138e70bf7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4390d627bf25dbda727ee2c91c1db59d5a0e1e23 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 18 19:16:32 2014 -0400 This should hopefully fix the C++ compilation issues with libgl. ----------------------------------------------------------------------- Summary of changes: gl-api.c | 8 ++++++++ include/gl.h | 2 +- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/gl-api.c b/gl-api.c index c50fc69..d2b0be2 100755 --- a/gl-api.c +++ b/gl-api.c @@ -72,6 +72,14 @@ static GLubyte GL_ENABLE_SUPERSAMP = 0; static GLubyte GL_FACE_FRONT = 0; static GLubyte GL_CLAMP_ST = 0; +/* Primitive 2D Position Submission */ +void (*glVertex2f)(float, float); +void (*glVertex2fv)(float *); + +/* Primitive 3D Position Submission */ +void (*glVertex3f)(float, float, float); +void (*glVertex3fv)(float *); + #define GL_CLAMP_U 0x0F #define GL_CLAMP_V 0xF0 #define GL_CLAMP_UV 0xFF diff --git a/include/gl.h b/include/gl.h index 17dd552..b97b4d8 100755 --- a/include/gl.h +++ b/include/gl.h @@ -317,7 +317,7 @@ __BEGIN_DECLS #define GL_FALSE 0 #define GL_TRUE 1 -#define GLAPI +#define GLAPI extern #define APIENTRY /* Initialize the GL pipeline. GL will initialize the PVR. */ hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-08-17 22:05:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 05fde8a4b072051b2348c77d366f6f6296a855d0 (commit) from 4334e73dc6f460c09cc9895cd44cf7c970f1c668 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 05fde8a4b072051b2348c77d366f6f6296a855d0 Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sun Aug 17 15:04:50 2014 -0700 #Fixed problem in glut.h causing conflict when linking the library against c++ programs ----------------------------------------------------------------------- Summary of changes: libgl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libgl b/libgl index aca082f..9dde472 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit aca082fa8b1aacfab29998a19f5810c2fe1f37f5 +Subproject commit 9dde4722939f8e1192291a545ad98bd138e70bf7 hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-08-17 22:03:36
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via 9dde4722939f8e1192291a545ad98bd138e70bf7 (commit) from aca082fa8b1aacfab29998a19f5810c2fe1f37f5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9dde4722939f8e1192291a545ad98bd138e70bf7 Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sun Aug 17 15:03:16 2014 -0700 #Fixed problem in glut.h causing conflict when linking the library against c++ programs ----------------------------------------------------------------------- Summary of changes: include/glut.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/glut.h b/include/glut.h index 4284b04..c77a5cd 100755 --- a/include/glut.h +++ b/include/glut.h @@ -9,6 +9,9 @@ #ifndef __GL_GLUT_H #define __GL_GLUT_H +#include <sys/cdefs.h> +__BEGIN_DECLS + #include <GL/gl.h> /* Flush the Submitted Primitive Data to the GPU for render to screen */ @@ -22,4 +25,6 @@ GLAPI void APIENTRY glutSwapBuffersToTexture(void *dst, GLsizei *x, GLsizei *y); next frame rendered */ GLAPI void APIENTRY glutCopyBufferToTexture(void *dst, GLsizei *x, GLsizei *y); +__END_DECLS + #endif /* !__GL_GLUT_H */ hooks/post-receive -- The KallistiOS port of OpenGL. |
From: PH3NOM <ph...@us...> - 2014-08-17 21:51:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 98c43f8bd0680cc65408acf43871f2b29f6285d3 (commit) from a52657c2c8cf6353cf2b3339c48438083110cf0d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 98c43f8bd0680cc65408acf43871f2b29f6285d3 Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sun Aug 17 14:51:03 2014 -0700 #Updated examples/dreamcast/cpp/gltest for use with new Open GL API. Also fixed a case sensitive problem on some OS's on the specular demo. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/cpp/gltest/Makefile | 2 +- examples/dreamcast/cpp/gltest/gltest.cpp | 688 +++++++++++--------- .../{kgl/basic/gl => cpp/gltest}/romdisk/glass.pvr | Bin 32800 -> 32800 bytes examples/dreamcast/kgl/demos/specular/font.c | 2 +- 4 files changed, 399 insertions(+), 293 deletions(-) copy examples/dreamcast/{kgl/basic/gl => cpp/gltest}/romdisk/glass.pvr (100%) diff --git a/examples/dreamcast/cpp/gltest/Makefile b/examples/dreamcast/cpp/gltest/Makefile index 7940a2c..2071cc5 100644 --- a/examples/dreamcast/cpp/gltest/Makefile +++ b/examples/dreamcast/cpp/gltest/Makefile @@ -17,7 +17,7 @@ rm-elf: -rm -f $(TARGET) romdisk.* $(TARGET): $(OBJS) romdisk.o - kos-c++ -o $(TARGET) $(OBJS) romdisk.o -lgl -lpcx -lkosutils + kos-c++ -o $(TARGET) $(OBJS) romdisk.o -lgl -lkosutils romdisk.img: $(KOS_GENROMFS) -f romdisk.img -d romdisk -v diff --git a/examples/dreamcast/cpp/gltest/gltest.cpp b/examples/dreamcast/cpp/gltest/gltest.cpp index 4913dfe..67ae851 100644 --- a/examples/dreamcast/cpp/gltest/gltest.cpp +++ b/examples/dreamcast/cpp/gltest/gltest.cpp @@ -1,291 +1,397 @@ -/* KallistiOS ##version## - - gltest.cpp - (c)2001-2002 Dan Potter -*/ - -#include <kos.h> -#include <GL/gl.h> -#include <GL/glu.h> -#include <pcx/pcx.h> - -/* - -This is a really simple KallistiGL example. It shows off several things: -basic matrix control, perspective, the AUTO_UV feature, and controlling -the image with maple input. - -Thanks to NeHe's tutorials for the crate image. - -This version is written in C++ and uses some basic C++ operations to test -various things about C++ functionality. - -*/ - -class Object { -protected: - float tx, ty, tz; - -public: - Object(float dtx, float dty, float dtz) { - tx = dtx; - ty = dty; - tz = dtz; - printf("Object::Object called\n"); - } - - virtual ~Object() { - printf("Object::~Object called\n"); - } - - virtual void draw() { - } -}; - -class Cube : public Object { -private: - float r; - -public: - Cube(float px, float py, float pz) - : Object(px, py, pz) { - r = 0.0f; - printf("Cube::Cube called\n"); - } - - virtual ~Cube() { - printf("Cube::~Cube called\n"); - } - - void rotate(float dr) { - r += dr; - } - - /* Draw a cube centered around 0,0,0. Note the total lack of glTexCoord2f(), - even though the cube is in fact getting textured! This is KGL's AUTO_UV - feature: turn it on and it assumes you're putting on the texture on - the quad in the order 0,0; 1,0; 1,1; 0,1. This only works for quads. */ - virtual void draw() { - glPushMatrix(); - glTranslatef(tx, ty, tz); - glRotatef(r, 1.0f, 0.0f, 1.0f); - - glBegin(GL_QUADS); - - /* Front face */ - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, 1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - - /* Back face */ - glVertex3f(-1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, 1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - - /* Left face */ - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - glVertex3f(-1.0f, -1.0f, -1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - - /* Right face */ - glVertex3f(1.0f, 1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glVertex3f(1.0f, 1.0f, 1.0f); - - /* Top face */ - glVertex3f(1.0f, 1.0f, 1.0f); - glVertex3f(-1.0f, 1.0f, 1.0f); - glVertex3f(-1.0f, 1.0f, -1.0f); - glVertex3f(1.0f, 1.0f, -1.0f); - - /* Bottom face */ - glVertex3f(1.0f, -1.0f, -1.0f); - glVertex3f(-1.0f, -1.0f, -1.0f); - glVertex3f(-1.0f, -1.0f, 1.0f); - glVertex3f(1.0f, -1.0f, 1.0f); - glEnd(); - - glPopMatrix(); - } -}; - -/* Note that ctors/dtors aren't really supported right now because of the - problems related to initialization; i.e., when main() is called, ctors - ought to have been called, but if they do any KOS specific stuff, it - will work (or worse, crash). I'm open to suggestions on fixing it. */ -class CtorDtorTest { -public: - CtorDtorTest() { - printf("CtorDtorTest::CtorDtorTest called\n"); - } - virtual ~CtorDtorTest() { - printf("CtorDtorTest::~CtorDtorTest called\n"); - } -} test_object, test_object2; - -/* Load a texture using pcx_load_texture and glKosTex2D */ -void loadtxr(const char *fn, GLuint *txr) { - kos_img_t img; - pvr_ptr_t txaddr; - - if(pcx_to_img(fn, &img) < 0) { - printf("can't load %s\n", fn); - return; - } - - txaddr = pvr_mem_malloc(img.w * img.h * 2); - pvr_txr_load_kimg(&img, txaddr, PVR_TXRLOAD_INVERT_Y); - kos_img_free(&img, 0); - - glGenTextures(1, txr); - glBindTexture(GL_TEXTURE_2D, *txr); - glKosTex2D(GL_RGB565_TWID, img.w, img.h, txaddr); -} - -extern uint8 romdisk[]; -KOS_INIT_ROMDISK(romdisk); - -int main(int argc, char **argv) { - maple_device_t *cont; - cont_state_t *state; - float r = 0.0f; - float dr = 2.0f; - float z = -14.0f; - GLuint texture; - int trans = 0; - - /* Initialize KOS */ - dbglog_set_level(DBG_WARNING); - pvr_init_defaults(); - - printf("gltest beginning\n"); - - /* Get basic stuff initialized */ - glKosInit(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f); - glMatrixMode(GL_MODELVIEW); - glEnable(GL_TEXTURE_2D); - glEnable(GL_KOS_AUTO_UV); - - /* Expect CW vertex order */ - glFrontFace(GL_CW); - - /* Enable Transparancy */ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - /* Load a texture and make it look nice */ - loadtxr("/rd/crate.pcx", &texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA); - - - printf("texture is %08x\n", texture); - - Cube *cubes[4] = { - new Cube(-5.0f, 0.0f, 0.0f), - new Cube(5.0f, 0.0f, 0.0f), - new Cube(0.0f, 5.0f, 0.0f), - new Cube(0.0f, -5.0f, 0.0f) - }; - cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - - while(1) { - /* Check key status */ - state = (cont_state_t *)maple_dev_status(cont); - - if(!state) { - printf("Error reading controller\n"); - break; - } - - if(state->buttons & CONT_START) - break; - - if(state->buttons & CONT_DPAD_UP) - z -= 0.1f; - - if(state->buttons & CONT_DPAD_DOWN) - z += 0.1f; - - if(state->buttons & CONT_DPAD_LEFT) { - /* If manual rotation is requested, then stop - the automated rotation */ - dr = 0.0f; - - for(int i = 0; i < 4; i++) - cubes[i]->rotate(- 2.0f); - - r -= 2.0f; - } - - if(state->buttons & CONT_DPAD_RIGHT) { - dr = 0.0f; - - for(int i = 0; i < 4; i++) - cubes[i]->rotate(+ 2.0f); - - r += 2.0f; - } - - if(state->buttons & CONT_A) { - /* This weird logic is to avoid bouncing back - and forth before the user lets go of the - button. */ - if(!(trans & 0x1000)) { - if(trans == 0) - trans = 0x1001; - else - trans = 0x1000; - } - } - else { - trans &= ~0x1000; - } - - for(int i = 0; i < 4; i++) - cubes[i]->rotate(dr); - - r += dr; - - /* Begin frame */ - glKosBeginFrame(); - - /* Draw four objects */ - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, z); - glRotatef(r, 0.0f, 1.0f, 0.5f); - - cubes[0]->draw(); - cubes[1]->draw(); - - /* Potentially do two as translucent */ - if(trans & 1) { - glKosFinishList(); - glColor4f(1.0f, 1.0f, 1.0f, 0.5f); - glDisable(GL_CULL_FACE); - } - - cubes[2]->draw(); - cubes[3]->draw(); - - if(trans & 1) { - glEnable(GL_CULL_FACE); - } - - /* Finish the frame */ - glKosFinishFrame(); - } - - for(int i = 0; i < 4; i++) - delete cubes[i]; - - return 0; -} - - +/* KallistiOS ##version## + + gltest.cpp + (c)2014 Josh Pearson + (c)2001-2002 Dan Potter +*/ + +#include <kos.h> +#include <GL/gl.h> +#include <GL/glu.h> +#include <GL/glut.h> + +/* + +This is a really simple KallistiGL example. It shows off several things: +basic matrix control, perspective, and controlling the image with maple input. + +Thanks to NeHe's tutorials for the crate image. + +This version is written in C++ and uses some basic C++ operations to test +various things about C++ functionality. + +*/ + +class Object { +protected: + float tx, ty, tz; + +public: + Object(float dtx, float dty, float dtz) { + tx = dtx; + ty = dty; + tz = dtz; + printf("Object::Object called\n"); + } + + virtual ~Object() { + printf("Object::~Object called\n"); + } + + virtual void draw() { + } +}; + +class Cube : public Object { +private: + float r; + +public: + Cube(float px, float py, float pz) + : Object(px, py, pz) { + r = 0.0f; + printf("Cube::Cube called\n"); + } + + virtual ~Cube() { + printf("Cube::~Cube called\n"); + } + + void rotate(float dr) { + r += dr; + } + + /* Draw a cube centered around 0,0,0. */ + virtual void draw() { + glPushMatrix(); + glTranslatef(tx, ty, tz); + glRotatef(r, 1.0f, 0.0f, 1.0f); + + float uv[4][2] = { { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + { 0.0f, 1.0f } }; + + glBegin(GL_QUADS); + + /* Front face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(-1.0f, 1.0f, 1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(1.0f, 1.0f, 1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(1.0f, -1.0f, 1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(-1.0f, -1.0f, 1.0f); + + /* Back face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(1.0f, 1.0f, -1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Left face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(-1.0f, 1.0f, 1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(-1.0f, -1.0f, 1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(-1.0f, 1.0f, -1.0f); + + /* Right face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(1.0f, 1.0f, -1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(1.0f, -1.0f, 1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(1.0f, 1.0f, 1.0f); + + /* Top face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(1.0f, 1.0f, 1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(-1.0f, 1.0f, 1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(-1.0f, 1.0f, -1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(1.0f, 1.0f, -1.0f); + + /* Bottom face */ + glTexCoord2fv(&uv[0][0]); + glVertex3f(1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[1][0]); + glVertex3f(-1.0f, -1.0f, -1.0f); + glTexCoord2fv(&uv[2][0]); + glVertex3f(-1.0f, -1.0f, 1.0f); + glTexCoord2fv(&uv[3][0]); + glVertex3f(1.0f, -1.0f, 1.0f); + + glEnd(); + + glPopMatrix(); + } +}; + +/* Note that ctors/dtors aren't really supported right now because of the + problems related to initialization; i.e., when main() is called, ctors + ought to have been called, but if they do any KOS specific stuff, it + will work (or worse, crash). I'm open to suggestions on fixing it. */ +class CtorDtorTest { +public: + CtorDtorTest() { + printf("CtorDtorTest::CtorDtorTest called\n"); + } + virtual ~CtorDtorTest() { + printf("CtorDtorTest::~CtorDtorTest called\n"); + } +} test_object, test_object2; + +/* Load a PVR texture using glTexImage2D */ +void loadtxr(const char *fname, GLuint *txr) { +#define PVR_HDR_SIZE 0x20 + FILE *tex = NULL; + unsigned char *texBuf; + unsigned int texSize; + + tex = fopen(fname, "rb"); + + if(tex == NULL) { + printf("FILE READ ERROR: %s\n", fname); + + while(1); + } + + fseek(tex, 0, SEEK_END); + texSize = ftell(tex); + + texBuf = (unsigned char*)malloc(texSize); + fseek(tex, 0, SEEK_SET); + fread(texBuf, 1, texSize, tex); + fclose(tex); + + int texW = texBuf[PVR_HDR_SIZE - 4] | texBuf[PVR_HDR_SIZE - 3] << 8; + int texH = texBuf[PVR_HDR_SIZE - 2] | texBuf[PVR_HDR_SIZE - 1] << 8; + int texFormat, texColor; + + switch((unsigned int)texBuf[PVR_HDR_SIZE - 8]) { + case 0x00: + texColor = PVR_TXRFMT_ARGB1555; + break; //(bilevel translucent alpha 0,255) + + case 0x01: + texColor = PVR_TXRFMT_RGB565; + break; //(non translucent RGB565 ) + + case 0x02: + texColor = PVR_TXRFMT_ARGB4444; + break; //(translucent alpha 0-255) + ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-08-17 01:34:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The collection of ports that can be used in KallistiOS programs.". The branch, master has been updated via 4334e73dc6f460c09cc9895cd44cf7c970f1c668 (commit) from 714b9654ce3b3d2dffdc5f9cf53f5f65243ca31a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4334e73dc6f460c09cc9895cd44cf7c970f1c668 Author: Lawrence Sebald <ljs...@us...> Date: Sat Aug 16 21:34:11 2014 -0400 Update submodule versions in kos-ports. ----------------------------------------------------------------------- Summary of changes: SDL | 2 +- libgl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SDL b/SDL index dd770d5..10b82d3 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit dd770d5a611fcc80d9579b651b7476b851851b3f +Subproject commit 10b82d38e762d9e706ebbb0a0d6b43c5d51b076a diff --git a/libgl b/libgl index efe60e2..aca082f 160000 --- a/libgl +++ b/libgl @@ -1 +1 @@ -Subproject commit efe60e2ccddd43bde6dd412fcf73843b1239da9d +Subproject commit aca082fa8b1aacfab29998a19f5810c2fe1f37f5 hooks/post-receive -- The collection of ports that can be used in KallistiOS programs. |
From: PH3NOM <ph...@us...> - 2014-08-16 19:13:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a52657c2c8cf6353cf2b3339c48438083110cf0d (commit) from 46bf3f12ec1b9ea1eb5f4321bf81cb75cb594b9f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a52657c2c8cf6353cf2b3339c48438083110cf0d Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sat Aug 16 12:13:16 2014 -0700 #Initial Commit for new Open GL API examples, replacing old KGL examples ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/kgl/basic/Makefile | 3 +- examples/dreamcast/kgl/basic/elements/Makefile | 38 + examples/dreamcast/kgl/basic/elements/main.c | 118 ++ .../dreamcast/kgl/basic/elements/pvr-texture.c | 148 +++ .../kgl/basic/elements/romdisk/wp001vq.pvr | Bin 0 -> 67616 bytes examples/dreamcast/kgl/basic/gl/Makefile | 71 +- examples/dreamcast/kgl/basic/gl/gltest.c | 586 ++++++---- examples/dreamcast/kgl/basic/gl/romdisk/crate.pcx | Bin 66451 -> 0 bytes examples/dreamcast/kgl/basic/gl/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/basic/scissor/Makefile | 74 +- .../kgl/basic/scissor/romdisk/checker.pcx | Bin 1153 -> 0 bytes .../dreamcast/kgl/basic/scissor/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/basic/scissor/scissor.c | 775 +++++++------ examples/dreamcast/kgl/basic/texenv/Makefile | 35 - .../dreamcast/kgl/basic/texenv/romdisk/checker.pcx | Bin 961 -> 0 bytes .../dreamcast/kgl/basic/texenv/romdisk/crate.pcx | Bin 66451 -> 0 bytes .../dreamcast/kgl/basic/texenv/romdisk/kgl.tga | Bin 65580 -> 0 bytes examples/dreamcast/kgl/basic/texenv/texenv.c | 198 ---- examples/dreamcast/kgl/basic/texwrap/Makefile | 37 - .../kgl/basic/texwrap/romdisk/checker.pcx | Bin 1153 -> 0 bytes examples/dreamcast/kgl/basic/texwrap/texwrap.c | 172 --- examples/dreamcast/kgl/basic/txrenv/Makefile | 38 + examples/dreamcast/kgl/basic/txrenv/main.c | 243 ++++ .../kgl/basic/txrenv/romdisk/FlareWS_256.pvr | Bin 0 -> 131104 bytes .../dreamcast/kgl/basic/txrenv/romdisk/wp001vq.pvr | Bin 0 -> 67616 bytes examples/dreamcast/kgl/basic/vfzclip/Makefile | 35 - .../dreamcast/kgl/basic/vfzclip/romdisk/crate.pcx | Bin 66451 -> 0 bytes examples/dreamcast/kgl/basic/vfzclip/vfzclip.c | 206 ---- examples/dreamcast/kgl/basic/vq/Makefile | 63 +- examples/dreamcast/kgl/basic/vq/fruit.jpg | Bin 19754 -> 19754 bytes examples/dreamcast/kgl/basic/vq/vq-example.c | 403 ++++---- examples/dreamcast/kgl/basic/zclip_arrays/Makefile | 38 + examples/dreamcast/kgl/basic/zclip_arrays/main.c | 103 ++ .../dreamcast/kgl/basic/zclip_arrays/pvr-texture.c | 148 +++ .../kgl/basic/zclip_arrays/romdisk/wp001vq.pvr | Bin 0 -> 67616 bytes examples/dreamcast/kgl/benchmarks/Makefile | 6 +- .../dreamcast/kgl/benchmarks/quadmark/Makefile | 63 +- .../dreamcast/kgl/benchmarks/quadmark/quadmark.c | 360 +++--- examples/dreamcast/kgl/benchmarks/trimark/Makefile | 61 +- .../dreamcast/kgl/benchmarks/trimark/trimark.c | 356 +++--- .../dreamcast/kgl/benchmarks/tristripmark/Makefile | 32 + .../kgl/benchmarks/tristripmark/tristripmark.c | 181 +++ examples/dreamcast/kgl/demos/Makefile | 38 +- examples/dreamcast/kgl/demos/blur/Makefile | 38 + examples/dreamcast/kgl/demos/blur/main.c | 369 ++++++ examples/dreamcast/kgl/demos/blur/pvr-texture.c | 144 +++ .../dreamcast/kgl/demos/blur/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/demos/bubbles/Makefile | 29 - examples/dreamcast/kgl/demos/bubbles/bubbles.c | 302 ----- examples/dreamcast/kgl/demos/mipmap/Makefile | 38 + examples/dreamcast/kgl/demos/mipmap/main.c | 138 +++ examples/dreamcast/kgl/demos/mipmap/pvr-texture.c | 144 +++ .../dreamcast/kgl/demos/mipmap/romdisk/MP_512.pvr | Bin 0 -> 524320 bytes .../kgl/demos/multitexture-arrays/Makefile | 38 + .../dreamcast/kgl/demos/multitexture-arrays/main.c | 115 ++ .../kgl/demos/multitexture-arrays/pvr-texture.c | 145 +++ .../multitexture-arrays/romdisk/FlareWS_256.pvr | Bin 0 -> 131104 bytes .../demos/multitexture-arrays/romdisk/wp001vq.pvr | Bin 0 -> 67616 bytes examples/dreamcast/kgl/demos/multitexture/Makefile | 38 + examples/dreamcast/kgl/demos/multitexture/main.c | 145 +++ .../dreamcast/kgl/demos/multitexture/pvr-texture.c | 145 +++ .../kgl/demos/multitexture/romdisk/FlareWS_256.pvr | Bin 0 -> 131104 bytes .../kgl/demos/multitexture/romdisk/wp001vq.pvr | Bin 0 -> 67616 bytes examples/dreamcast/kgl/demos/specular/Makefile | 37 + examples/dreamcast/kgl/demos/specular/font.c | 79 ++ examples/dreamcast/kgl/demos/specular/font.h | 35 + examples/dreamcast/kgl/demos/specular/input.c | 64 ++ examples/dreamcast/kgl/demos/specular/input.h | 30 + examples/dreamcast/kgl/demos/specular/main.c | 1177 ++++++++++++++++++++ .../dreamcast/kgl/demos/specular/romdisk/FONT0.PVR | Bin 0 -> 67616 bytes .../kgl/demos/specular/romdisk/brick_w1.pvr | Bin 0 -> 524320 bytes examples/dreamcast/kgl/demos/specular/texture.c | 110 ++ examples/dreamcast/kgl/demos/specular/texture.h | 15 + examples/dreamcast/kgl/demos/specular/timer.c | 20 + examples/dreamcast/kgl/demos/specular/timer.h | 18 + examples/dreamcast/kgl/demos/specular/vector.c | 28 + examples/dreamcast/kgl/demos/specular/vector.h | 23 + examples/dreamcast/kgl/demos/tunnel/Makefile | 37 - examples/dreamcast/kgl/demos/tunnel/README | 13 - examples/dreamcast/kgl/demos/tunnel/menu.cpp | 190 ---- examples/dreamcast/kgl/demos/tunnel/menu.h | 65 -- examples/dreamcast/kgl/demos/tunnel/plprint.cpp | 48 - examples/dreamcast/kgl/demos/tunnel/plprint.h | 22 - examples/dreamcast/kgl/demos/tunnel/romdisk/bw.pcx | Bin 78181 -> 0 bytes .../kgl/demos/tunnel/romdisk/courier-bold.txf | Bin 9292 -> 0 bytes .../dreamcast/kgl/demos/tunnel/romdisk/tile.pcx | Bin 65945 -> 0 bytes examples/dreamcast/kgl/demos/tunnel/tunnel.cpp | 523 --------- examples/dreamcast/kgl/demos/tunnel/tunneldat.c | 87 -- examples/dreamcast/kgl/nehe/nehe02/Makefile | 60 +- examples/dreamcast/kgl/nehe/nehe02/main.c | 83 ++ examples/dreamcast/kgl/nehe/nehe02/nehe02.c | 92 -- examples/dreamcast/kgl/nehe/nehe05/Makefile | 60 +- examples/dreamcast/kgl/nehe/nehe05/main.c | 143 +++ examples/dreamcast/kgl/nehe/nehe05/nehe05.c | 156 --- examples/dreamcast/kgl/nehe/nehe06/Makefile | 74 +- examples/dreamcast/kgl/nehe/nehe06/main.c | 266 +++++ examples/dreamcast/kgl/nehe/nehe06/nehe06.c | 184 --- .../dreamcast/kgl/nehe/nehe06/romdisk/NeHe.pcx | Bin 23165 -> 0 bytes .../dreamcast/kgl/nehe/nehe06/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/nehe/nehe08/Makefile | 74 +- examples/dreamcast/kgl/nehe/nehe08/main.c | 324 ++++++ examples/dreamcast/kgl/nehe/nehe08/nehe08.c | 252 ----- .../dreamcast/kgl/nehe/nehe08/romdisk/glass.pcx | Bin 19121 -> 0 bytes .../dreamcast/kgl/nehe/nehe08/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/nehe/nehe09/Makefile | 74 +- examples/dreamcast/kgl/nehe/nehe09/main.c | 270 +++++ examples/dreamcast/kgl/nehe/nehe09/nehe09.c | 209 ---- .../dreamcast/kgl/nehe/nehe09/romdisk/Star.pcx | Bin 16909 -> 0 bytes .../dreamcast/kgl/nehe/nehe09/romdisk/star.pvr | Bin 0 -> 6176 bytes examples/dreamcast/kgl/nehe/nehe16/Makefile | 71 +- examples/dreamcast/kgl/nehe/nehe16/nehe16.c | 599 ++++++----- .../dreamcast/kgl/nehe/nehe16/romdisk/crate.pcx | Bin 66451 -> 0 bytes .../dreamcast/kgl/nehe/nehe16/romdisk/glass.pvr | Bin 0 -> 32800 bytes examples/dreamcast/kgl/nehe/nehe26/Makefile | 73 +- examples/dreamcast/kgl/nehe/nehe26/data/txt2bin.c | 2 +- examples/dreamcast/kgl/nehe/nehe26/main.c | 383 +++++++ examples/dreamcast/kgl/nehe/nehe26/nehe26.c | 400 ------- .../dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin | Bin 5836 -> 5836 bytes .../dreamcast/kgl/nehe/nehe26/romdisk/torus.bin | Bin 5836 -> 5836 bytes .../dreamcast/kgl/nehe/nehe26/romdisk/tube.bin | Bin 5836 -> 5836 bytes 120 files changed, 7803 insertions(+), 5124 deletions(-) mode change 100644 => 100755 examples/dreamcast/kgl/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/basic/Makefile create mode 100755 examples/dreamcast/kgl/basic/elements/Makefile create mode 100755 examples/dreamcast/kgl/basic/elements/main.c create mode 100755 examples/dreamcast/kgl/basic/elements/pvr-texture.c create mode 100755 examples/dreamcast/kgl/basic/elements/romdisk/wp001vq.pvr mode change 100644 => 100755 examples/dreamcast/kgl/basic/gl/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/basic/gl/gltest.c delete mode 100644 examples/dreamcast/kgl/basic/gl/romdisk/crate.pcx create mode 100755 examples/dreamcast/kgl/basic/gl/romdisk/glass.pvr mode change 100644 => 100755 examples/dreamcast/kgl/basic/scissor/Makefile delete mode 100644 examples/dreamcast/kgl/basic/scissor/romdisk/checker.pcx create mode 100755 examples/dreamcast/kgl/basic/scissor/romdisk/glass.pvr mode change 100644 => 100755 examples/dreamcast/kgl/basic/scissor/scissor.c delete mode 100644 examples/dreamcast/kgl/basic/texenv/Makefile delete mode 100644 examples/dreamcast/kgl/basic/texenv/romdisk/checker.pcx delete mode 100644 examples/dreamcast/kgl/basic/texenv/romdisk/crate.pcx delete mode 100644 examples/dreamcast/kgl/basic/texenv/romdisk/kgl.tga delete mode 100644 examples/dreamcast/kgl/basic/texenv/texenv.c delete mode 100644 examples/dreamcast/kgl/basic/texwrap/Makefile delete mode 100644 examples/dreamcast/kgl/basic/texwrap/romdisk/checker.pcx delete mode 100644 examples/dreamcast/kgl/basic/texwrap/texwrap.c create mode 100755 examples/dreamcast/kgl/basic/txrenv/Makefile create mode 100755 examples/dreamcast/kgl/basic/txrenv/main.c create mode 100755 examples/dreamcast/kgl/basic/txrenv/romdisk/FlareWS_256.pvr create mode 100755 examples/dreamcast/kgl/basic/txrenv/romdisk/wp001vq.pvr delete mode 100644 examples/dreamcast/kgl/basic/vfzclip/Makefile delete mode 100644 examples/dreamcast/kgl/basic/vfzclip/romdisk/crate.pcx delete mode 100644 examples/dreamcast/kgl/basic/vfzclip/vfzclip.c mode change 100644 => 100755 examples/dreamcast/kgl/basic/vq/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/basic/vq/fruit.jpg mode change 100644 => 100755 examples/dreamcast/kgl/basic/vq/vq-example.c create mode 100755 examples/dreamcast/kgl/basic/zclip_arrays/Makefile create mode 100755 examples/dreamcast/kgl/basic/zclip_arrays/main.c create mode 100755 examples/dreamcast/kgl/basic/zclip_arrays/pvr-texture.c create mode 100755 examples/dreamcast/kgl/basic/zclip_arrays/romdisk/wp001vq.pvr mode change 100644 => 100755 examples/dreamcast/kgl/benchmarks/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/benchmarks/quadmark/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c mode change 100644 => 100755 examples/dreamcast/kgl/benchmarks/trimark/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/benchmarks/trimark/trimark.c create mode 100755 examples/dreamcast/kgl/benchmarks/tristripmark/Makefile create mode 100755 examples/dreamcast/kgl/benchmarks/tristripmark/tristripmark.c mode change 100644 => 100755 examples/dreamcast/kgl/demos/Makefile create mode 100755 examples/dreamcast/kgl/demos/blur/Makefile create mode 100755 examples/dreamcast/kgl/demos/blur/main.c create mode 100755 examples/dreamcast/kgl/demos/blur/pvr-texture.c create mode 100755 examples/dreamcast/kgl/demos/blur/romdisk/glass.pvr delete mode 100644 examples/dreamcast/kgl/demos/bubbles/Makefile delete mode 100644 examples/dreamcast/kgl/demos/bubbles/bubbles.c create mode 100755 examples/dreamcast/kgl/demos/mipmap/Makefile create mode 100755 examples/dreamcast/kgl/demos/mipmap/main.c create mode 100755 examples/dreamcast/kgl/demos/mipmap/pvr-texture.c create mode 100755 examples/dreamcast/kgl/demos/mipmap/romdisk/MP_512.pvr create mode 100755 examples/dreamcast/kgl/demos/multitexture-arrays/Makefile create mode 100755 examples/dreamcast/kgl/demos/multitexture-arrays/main.c create mode 100755 examples/dreamcast/kgl/demos/multitexture-arrays/pvr-texture.c create mode 100755 examples/dreamcast/kgl/demos/multitexture-arrays/romdisk/FlareWS_256.pvr create mode 100755 examples/dreamcast/kgl/demos/multitexture-arrays/romdisk/wp001vq.pvr create mode 100755 examples/dreamcast/kgl/demos/multitexture/Makefile create mode 100755 examples/dreamcast/kgl/demos/multitexture/main.c create mode 100755 examples/dreamcast/kgl/demos/multitexture/pvr-texture.c create mode 100755 examples/dreamcast/kgl/demos/multitexture/romdisk/FlareWS_256.pvr create mode 100755 examples/dreamcast/kgl/demos/multitexture/romdisk/wp001vq.pvr create mode 100755 examples/dreamcast/kgl/demos/specular/Makefile create mode 100755 examples/dreamcast/kgl/demos/specular/font.c create mode 100755 examples/dreamcast/kgl/demos/specular/font.h create mode 100755 examples/dreamcast/kgl/demos/specular/input.c create mode 100755 examples/dreamcast/kgl/demos/specular/input.h create mode 100755 examples/dreamcast/kgl/demos/specular/main.c create mode 100755 examples/dreamcast/kgl/demos/specular/romdisk/FONT0.PVR create mode 100755 examples/dreamcast/kgl/demos/specular/romdisk/brick_w1.pvr create mode 100755 examples/dreamcast/kgl/demos/specular/texture.c create mode 100755 examples/dreamcast/kgl/demos/specular/texture.h create mode 100755 examples/dreamcast/kgl/demos/specular/timer.c create mode 100755 examples/dreamcast/kgl/demos/specular/timer.h create mode 100755 examples/dreamcast/kgl/demos/specular/vector.c create mode 100755 examples/dreamcast/kgl/demos/specular/vector.h delete mode 100644 examples/dreamcast/kgl/demos/tunnel/Makefile delete mode 100644 examples/dreamcast/kgl/demos/tunnel/README delete mode 100644 examples/dreamcast/kgl/demos/tunnel/menu.cpp delete mode 100644 examples/dreamcast/kgl/demos/tunnel/menu.h delete mode 100644 examples/dreamcast/kgl/demos/tunnel/plprint.cpp delete mode 100644 examples/dreamcast/kgl/demos/tunnel/plprint.h delete mode 100644 examples/dreamcast/kgl/demos/tunnel/romdisk/bw.pcx delete mode 100644 examples/dreamcast/kgl/demos/tunnel/romdisk/courier-bold.txf delete mode 100644 examples/dreamcast/kgl/demos/tunnel/romdisk/tile.pcx delete mode 100644 examples/dreamcast/kgl/demos/tunnel/tunnel.cpp delete mode 100644 examples/dreamcast/kgl/demos/tunnel/tunneldat.c mode change 100644 => 100755 examples/dreamcast/kgl/nehe/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe02/Makefile create mode 100755 examples/dreamcast/kgl/nehe/nehe02/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe02/nehe02.c mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe05/Makefile create mode 100755 examples/dreamcast/kgl/nehe/nehe05/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe05/nehe05.c mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe06/Makefile create mode 100755 examples/dreamcast/kgl/nehe/nehe06/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe06/nehe06.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe06/romdisk/NeHe.pcx create mode 100755 examples/dreamcast/kgl/nehe/nehe06/romdisk/glass.pvr mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe08/Makefile create mode 100755 examples/dreamcast/kgl/nehe/nehe08/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe08/nehe08.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe08/romdisk/glass.pcx create mode 100755 examples/dreamcast/kgl/nehe/nehe08/romdisk/glass.pvr mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe09/Makefile create mode 100755 examples/dreamcast/kgl/nehe/nehe09/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe09/nehe09.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe09/romdisk/Star.pcx create mode 100755 examples/dreamcast/kgl/nehe/nehe09/romdisk/star.pvr mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe16/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe16/nehe16.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe16/romdisk/crate.pcx create mode 100755 examples/dreamcast/kgl/nehe/nehe16/romdisk/glass.pvr mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/data/Makefile mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/data/sphere.txt mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/data/torus.txt mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/data/tube.txt mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/data/txt2bin.c create mode 100755 examples/dreamcast/kgl/nehe/nehe26/main.c delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/nehe26.c mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin mode change 100644 => 100755 examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin diff --git a/examples/dreamcast/kgl/Makefile b/examples/dreamcast/kgl/Makefile old mode 100644 new mode 100755 diff --git a/examples/dreamcast/kgl/basic/Makefile b/examples/dreamcast/kgl/basic/Makefile old mode 100644 new mode 100755 index 0702082..50bd83b --- a/examples/dreamcast/kgl/basic/Makefile +++ b/examples/dreamcast/kgl/basic/Makefile @@ -2,12 +2,13 @@ # # examples/dreamcast/kgl/basic/Makefile # +# (c)2014 Josh Pearson # (c)2002 Paul Boese # # This will make all the examples, leaving only the elf files. # If you want to clean everything, use 'clean'. -SUBDIRS = gl scissor texenv texwrap vfzclip vq +SUBDIRS = elements gl scissor txrenv vq zclip_arrays all: $(patsubst %, _dir_%, $(SUBDIRS)) diff --git a/examples/dreamcast/kgl/basic/elements/Makefile b/examples/dreamcast/kgl/basic/elements/Makefile new file mode 100755 index 0000000..4d25cb7 --- /dev/null +++ b/examples/dreamcast/kgl/basic/elements/Makefile @@ -0,0 +1,38 @@ +# +# OpenGL Dreamcast Vertex Arrays Example +# (c)2014 Josh PH3NOM Pearson +# + +TARGET = gl-elements.elf + +OBJS = main.o pvr-texture.o + +OBJS += romdisk.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: + -rm -f $(TARGET) $(OBJS) + +rm-elf: + -rm -f $(TARGET) + +$(TARGET): $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \ + $(OBJS) $(OBJEXTRA) -L$(KOS_BASE)/lib -lgl -lm $(KOS_LIBS) + +romdisk.img: + $(KOS_GENROMFS) -f romdisk.img -d romdisk -v + +romdisk.o: romdisk.img + $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: + rm -f $(OBJS) + $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/kgl/basic/elements/main.c b/examples/dreamcast/kgl/basic/elements/main.c new file mode 100755 index 0000000..e3c8a8b --- /dev/null +++ b/examples/dreamcast/kgl/basic/elements/main.c @@ -0,0 +1,118 @@ +/* + KallistiOS 2.0.0 + + main.c + (c)2014 Josh Pearson + + Open GL example using Vertex Array Submission and GL Lighting. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <GL/glut.h> + +/* Load a PVR texture - located in pvr-texture.c */ +extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap); + +GLfloat VERTEX_ARRAY[4 * 3 * 2] = { -100.0f, -10.0f, 100.0f, + 100.0f, -10.0f, 100.0f, + 100.0f, -10.0f, -100.0f, + -100.0f, -10.0f, -100.0f + }; + +GLfloat TEXCOORD_ARRAY[4 * 2 * 2] = { 0, 0, + 1, 0, + 1, 1, + 0, 1, + 1, 0, + 0, 0, + 0, 1, + 1, 1 + }; + +GLfloat NORMAL_ARRAY[4 * 3 * 2] = { 0, -1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0, + 0, 1, 0 + }; + +GLubyte INDEX_ARRAY[4 * 2] = { 0, 1, 2, 3, + 4, 5, 6, 7 + }; + +/* Example using Open GL Vertex Array Submission using glDrawElements().*/ +static float rx = 1.0f; +void RenderCallback(GLuint texID) { + /* Enable KOS Near Z Vertex Clipping */ + glEnable(GL_KOS_NEARZ_CLIPPING); + + /* Set up Light1 - color it red */ + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + float lp[4] = { 0.0, 200.0, 0.0, 0.0 }; + float lc[3] = { 1.0f, 0.0f, 0.0f }; + glLightfv(GL_LIGHT0, GL_POSITION, lp); + glLightfv(GL_LIGHT0, GL_DIFFUSE, lc); + + /* Load Identity and rotate it a bit */ + glLoadIdentity(); + glRotatef(rx++, 0, 1, 0); + + /* Enable 2D Texturing and bind the Texture */ + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, texID); + + /* Bind Array Data */ + glNormalPointer(3, GL_FLOAT, 0, NORMAL_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORD_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, VERTEX_ARRAY); + + /* Render the Submitted Vertex Data */ + glDrawElements(GL_QUADS, 4 * 1, GL_UNSIGNED_BYTE, INDEX_ARRAY); + + /* Disable GL Vertex Lighting */ + glDisable(GL_LIGHT0); + glDisable(GL_LIGHTING); + + /* Disable GL KOS Near Z Vertex Clipping */ + glDisable(GL_KOS_NEARZ_CLIPPING); +} + +extern uint8 romdisk[]; +KOS_INIT_ROMDISK(romdisk); + +int main(int argc, char **argv) { + /* Notice we do not init the PVR here, that is handled by Open GL */ + glKosInit(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, vid_mode->width / vid_mode->height, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + + /* Load a PVR texture to OpenGL */ + GLuint texID = glTextureLoadPVR("/rd/wp001vq.pvr", 0, 0); + + while(1) { + /* Draw the "scene" */ + RenderCallback(texID); + + /* Finish the frame - Notice there is no glKosBegin/FinshFrame */ + glutSwapBuffers(); + } + + return 0; +} + diff --git a/examples/dreamcast/kgl/basic/elements/pvr-texture.c b/examples/dreamcast/kgl/basic/elements/pvr-texture.c new file mode 100755 index 0000000..8af2cf2 --- /dev/null +++ b/examples/dreamcast/kgl/basic/elements/pvr-texture.c @@ -0,0 +1,148 @@ +/* + KallistiOS 2.0.0 + + pvr-texture.c + (c)2014 Josh Pearson + + Load A PVR Texture to the PVR using Open GL +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <malloc.h> + +#include <GL/gl.h> +#include <GL/glu.h> +#include <GL/glut.h> + +#define PVR_HDR_SIZE 0x20 + +static GLuint PVR_TextureHeight(unsigned char *HDR); +static GLuint PVR_TextureWidth(unsigned char *HDR); +static GLuint PVR_TextureFormat(unsigned char *HDR); +static GLuint PVR_TextureColor(unsigned char *HDR); + +/* Load a PVR texture file into memory, and then bind the texture to Open GL. + fname is the name of the PVR texture file to be opened and read. + isMipMapped should be passed as 1 if the texture contains MipMap levels, 0 otherwise. + glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */ +GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) { + FILE *tex = NULL; + uint16 *TEX0 = NULL; + uint8 HDR[PVR_HDR_SIZE]; + GLuint texID, texSize, texW, texH, texFormat, texColor; + + /* Open the PVR texture file, and get its file size */ + tex = fopen(fname, "rb"); + + if(tex == NULL) { + printf("FILE READ ERROR: %s\n", fname); + + while(1); + } + + fseek(tex, 0, SEEK_END); + texSize = ftell(tex) - PVR_HDR_SIZE; + fseek(tex, 0, SEEK_SET); + + /* Read in the PVR texture file header */ + fread(HDR, 1, PVR_HDR_SIZE, tex); + + /* Extract some information from the PVR texture file header */ + texW = PVR_TextureWidth(HDR); + texH = PVR_TextureHeight(HDR); + texFormat = PVR_TextureFormat(HDR); + texColor = PVR_TextureColor(HDR); + + /* Allocate Some Memory for the texture. If we are using Open GL to build the MipMap, + we need to allocate enough space to hold the MipMap texture levels. */ + if(!isMipMapped && glMipMap) + TEX0 = malloc(glKosMipMapTexSize(texW, texH)); + else + TEX0 = malloc(texSize); + + fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */ + + /* If requested, tell Open GL to build the MipMap levels for the texture. */ ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: PH3NOM <ph...@us...> - 2014-08-16 18:16:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, master has been updated via aca082fa8b1aacfab29998a19f5810c2fe1f37f5 (commit) via d5077ae105062958bba96d7681a6b5930d6c160e (commit) via 5c5a0196c5d90e7fb02fd1904e4957ba3d4f25ca (commit) from efe60e2ccddd43bde6dd412fcf73843b1239da9d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aca082fa8b1aacfab29998a19f5810c2fe1f37f5 Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sat Aug 16 11:15:06 2014 -0700 #Initial Commit for new Open GL API, replacing the old KGL commit d5077ae105062958bba96d7681a6b5930d6c160e Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sat Aug 16 11:13:38 2014 -0700 #Initial Commit for new Open GL API, replacing the old KGL commit 5c5a0196c5d90e7fb02fd1904e4957ba3d4f25ca Author: U-PH3NOM-PC\PH3NOM <PH3NOM@PH3NOM-PC.(none)> Date: Sat Aug 16 11:09:37 2014 -0700 #Initial Commit for new Open GL API, replacing the old KGL ----------------------------------------------------------------------- Summary of changes: Makefile | 11 +- gl-api.c | 1358 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gl-api.h | 116 +++++ gl-arrays.c | 1039 +++++++++++++++++++++++++++++++++++++++++++ gl-arrays.h | 58 +++ gl-clip.c | 745 +++++++++++++++++++++++++++++++ gl-clip.h | 44 ++ gl-fog.c | 102 +++++ gl-light.c | 562 +++++++++++++++++++++++ gl-light.h | 51 +++ gl-matrix.c | 395 ++++++++++++++++ gl-pvr.c | 215 +++++++++ gl-pvr.h | 54 +++ gl-rgb.c | 116 +++++ gl-rgb.h | 63 +++ gl-sh4-light.S | 232 ++++++++++ gl-sh4.h | 52 +++ glblend.c | 77 ---- glclip.h | 96 ---- gldepth.c | 72 --- gldraw.c | 663 --------------------------- glfog.c | 178 -------- glinternal.h | 165 ------- glkos.c | 210 --------- gllight.c | 27 -- glmacros.h | 19 - glmisc.c | 230 ---------- glmodifier.c | 212 --------- glnzclip.c | 182 -------- gltex.c | 188 -------- gltrans.c | 518 --------------------- glvars.c | 101 ----- include/gl.h | 941 +++++++++++++++++++++------------------ include/glu.h | 67 ++- include/glut.h | 25 + 35 files changed, 5794 insertions(+), 3390 deletions(-) create mode 100755 gl-api.c create mode 100755 gl-api.h create mode 100755 gl-arrays.c create mode 100755 gl-arrays.h create mode 100755 gl-clip.c create mode 100755 gl-clip.h create mode 100755 gl-fog.c create mode 100755 gl-light.c create mode 100755 gl-light.h create mode 100755 gl-matrix.c create mode 100755 gl-pvr.c create mode 100755 gl-pvr.h create mode 100755 gl-rgb.c create mode 100755 gl-rgb.h create mode 100755 gl-sh4-light.S create mode 100755 gl-sh4.h delete mode 100644 glblend.c delete mode 100644 glclip.h delete mode 100644 gldepth.c delete mode 100644 gldraw.c delete mode 100644 glfog.c delete mode 100644 glinternal.h delete mode 100644 glkos.c delete mode 100644 gllight.c delete mode 100644 glmacros.h delete mode 100644 glmisc.c delete mode 100644 glmodifier.c delete mode 100644 glnzclip.c delete mode 100644 gltex.c delete mode 100644 gltrans.c delete mode 100644 glvars.c mode change 100644 => 100755 include/gl.h mode change 100644 => 100755 include/glu.h create mode 100755 include/glut.h diff --git a/Makefile b/Makefile index fe84986..b018d22 100755 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ # KallistiOS ##version## # -# addons/libgl Makefile -# (c)2001 Dan Potter +# kos-ports/libgl Makefile +# Copyright (C) 2013, 2014 Josh Pearson +# Copyright (C) 2014 Lawrence Sebald TARGET = libgl.a -OBJS = gldepth.o gldraw.o glkos.o gllight.o glmisc.o -OBJS += gltex.o gltrans.o glvars.o glblend.o glfog.o glmodifier.o glnzclip.o +OBJS = gl-rgb.o gl-fog.o gl-sh4-light.o gl-light.o gl-clip.o gl-pvr.o +OBJS += gl-arrays.o gl-matrix.o gl-api.o SUBDIRS = +KOS_CFLAGS += -ffast-math -O3 -Iinclude + defaultall: create_kos_link $(OBJS) subdirs linklib include $(KOS_BASE)/addons/Makefile.prefab diff --git a/gl-api.c b/gl-api.c new file mode 100755 index 0000000..c50fc69 --- /dev/null +++ b/gl-api.c @@ -0,0 +1,1358 @@ +/* KallistiGL for KallistiOS ##version## + + libgl/gl.h + Copyright (C) 2013-2014 Josh "PH3NOM" Pearson + + Some functionality adapted from the original KOS libgl: + Copyright (C) 2001 Dan Potter + Copyright (C) 2002 Benoit Miller + + This API implements much but not all of the OpenGL 1.1 for KallistiOS. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "gl.h" +#include "glu.h" +#include "gl-api.h" +#include "gl-sh4.h" +#include "gl-pvr.h" + +/* Texture Submission Functions ************************************************************************/ +/* The texutre sumbission uses a fixed-size buffer, that defaults to 1024 textures. + That means that you must manage your texture submission by calling glDelTextures(...) + when you are done using a texture that was created by glGenTextures(...). + The size of the texture buffer can be controlled by setting GL_MAX_TEXTURES on gl-pvr.h. + + glTexImage2D(..) is used for loading texture data to OpenGL that is located in Main RAM: + OpenGL will allocate VRAM for the texture, and copy the texture data from Main RAM to VRAM. + + glKosTexImage2D(...) is used for loading texture data to OpenGL that is already in VRAM: + This mode must be used for a render-to-texture if you are using glutSwapBuffersToTexture(). +*/ + +typedef struct { + GLenum target; + GLint level; + GLint border; + GLenum format; + GLenum type; + GLint filter, env; + GLuint width, height; + GLuint internalFormat; + GLvoid *data; +} glTexCxt; + +static glTexCxt GL_TEX_LIST[GL_MAX_TEXTURES]; +static GLint GL_BOUND_TEX = -1, GL_LAST_BOUND_TEX = -1, + GL_BOUND_TEX1 = -1, GL_LAST_BOUND_TEX1 = -1; + +static GLubyte BLEND_SRC = PVR_BLEND_ONE; +static GLubyte BLEND_DST = PVR_BLEND_ZERO; + +static GLubyte GL_SHADE_FUNC = PVR_SHADE_GOURAUD; + +static GLubyte GL_CULL_FUNC = PVR_CULLING_NONE; + +static GLubyte GL_DEPTH_CMP = PVR_DEPTHCMP_GEQUAL; +static GLubyte GL_DEPTH_ENABLE = PVR_DEPTHWRITE_ENABLE; + +static GLubyte GL_TEX_ENV = PVR_TXRENV_MODULATEALPHA; + +static GLubyte GL_ENABLE_CLIPZ = 0; +static GLubyte GL_ENABLE_LIGHTING = 0; +static GLubyte GL_ENABLE_SCISSOR = 0; +static GLubyte GL_ENABLE_FOG = 0; +static GLubyte GL_ENABLE_CULLING = 0; +static GLubyte GL_ENABLE_DEPTH_TEST = 0; +static GLubyte GL_ENABLE_SUPERSAMP = 0; + +static GLubyte GL_FACE_FRONT = 0; +static GLubyte GL_CLAMP_ST = 0; + +#define GL_CLAMP_U 0x0F +#define GL_CLAMP_V 0xF0 +#define GL_CLAMP_UV 0xFF + +#define GL_TEXTURE_0 1<<0 +#define GL_TEXTURE_1 1<<1 + +static GLuint GL_TEXTURE_ENABLED = 0; +static GLuint GL_CUR_ACTIVE_TEX = 0; + +void glActiveTexture(GLenum texture) { + if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + GL_MAX_TEXTURE_UNITS) + return; + + GL_CUR_ACTIVE_TEX = ((texture & 0xFF) - (GL_TEXTURE0 & 0xFF)); +} + +void glBindTexture(GLenum target, GLuint texture) { + if(target == GL_TEXTURE_2D) { + switch(GL_CUR_ACTIVE_TEX) { + case 0: + GL_BOUND_TEX = texture; + GL_LAST_BOUND_TEX = GL_BOUND_TEX; + break; + + case 1: + GL_BOUND_TEX1 = texture; + GL_LAST_BOUND_TEX1 = GL_BOUND_TEX1; + break; + } + } +} + +void glGetIntegerv(GLenum pname, GLint *params) { + switch(pname) { + case GL_ACTIVE_TEXTURE: + *params = GL_CUR_ACTIVE_TEX; + break; + + case GL_BLEND: + *params = _glKosList(); + break; + + case GL_BLEND_DST: + *params = BLEND_SRC; + break; + + case GL_BLEND_SRC: + *params = BLEND_DST; + break; + + case GL_CULL_FACE: + *params = GL_ENABLE_CULLING; + break; + + case GL_CULL_FACE_MODE: + *params = GL_CULL_FUNC; + break; + + case GL_DEPTH_FUNC: + *params = GL_DEPTH_CMP; + break; + + case GL_DEPTH_TEST: + *params = GL_ENABLE_DEPTH_TEST; + break; + + case GL_DEPTH_WRITEMASK: + *params = GL_DEPTH_ENABLE; + break; + + case GL_FRONT_FACE: + *params = GL_FACE_FRONT; + break; + + case GL_SCISSOR_TEST: + *params = GL_ENABLE_SCISSOR; + break; + + default: + *params = -1; // Indicate invalid parameter // + break; + } +} + +static void _glKosInitTextures() { + GLuint i; + + for(i = 0; i < GL_MAX_TEXTURES; i++) + GL_TEX_LIST[i].data = NULL; +} + +static GLuint _glKosNextTexture() { + GLint i; + + for(i = 0; i < GL_MAX_TEXTURES; i++) + if(GL_TEX_LIST[i].data == NULL) + return i; + + return 0; /* Invalid Texture! */ +} + +GLuint glKosMipMapTexSize(GLuint width, GLuint height) { + GLuint b = 0; + + while(width >= 1 && height >= 1) { + b += width * height * 2; + + if(width >= 1) + width /= 2; + + if(height >= 1) + height /= 2; + } + + return b; +} + +void glGenTextures(GLsizei n, GLuint *textures) { + while(n--) + *textures++ = _glKosNextTexture(); +} + +void glDelTextures(GLsizei n, GLuint *textures) { + while(n--) { + if(GL_TEX_LIST[*textures].data != NULL) { + pvr_mem_free(GL_TEX_LIST[*textures].data); + GL_TEX_LIST[*textures].data = NULL; + } + + textures++; + } +} + +void glTexImage2D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, GLvoid *data) { + if(target != GL_TEXTURE_2D) return; + + GL_TEX_LIST[GL_BOUND_TEX].target = target; + GL_TEX_LIST[GL_BOUND_TEX].level = level; + GL_TEX_LIST[GL_BOUND_TEX].border = border; + GL_TEX_LIST[GL_BOUND_TEX].format = format; + GL_TEX_LIST[GL_BOUND_TEX].type = type; + + GLuint bytes; + + if(!level) + bytes = width * height * 2; + else + bytes = glKosMipMapTexSize(width, height); + + if(format == PVR_TXRFMT_VQ_ENABLE) + bytes /= 4; + + GL_TEX_LIST[GL_BOUND_TEX].data = pvr_mem_malloc(bytes); + + GL_TEX_LIST[GL_BOUND_TEX].width = width; + GL_TEX_LIST[GL_BOUND_TEX].height = height; + GL_TEX_LIST[GL_BOUND_TEX].internalFormat = internalFormat; + + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; + + sq_cpy(GL_TEX_LIST[GL_BOUND_TEX].data, data, bytes); +} + +void glKosTexImage2D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, GLvoid *data) { + if(target != GL_TEXTURE_2D) return; + + GL_TEX_LIST[GL_BOUND_TEX].target = target; + GL_TEX_LIST[GL_BOUND_TEX].level = level; + GL_TEX_LIST[GL_BOUND_TEX].border = border; + GL_TEX_LIST[GL_BOUND_TEX].format = format; + GL_TEX_LIST[GL_BOUND_TEX].type = type; + + GL_TEX_LIST[GL_BOUND_TEX].data = data; + + GL_TEX_LIST[GL_BOUND_TEX].width = width; + GL_TEX_LIST[GL_BOUND_TEX].height = height; + GL_TEX_LIST[GL_BOUND_TEX].internalFormat = internalFormat; + + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; +} + +void glTexParameteri(GLenum target, GLenum pname, GLint param) { + if(target == GL_TEXTURE_2D) { + switch(pname) { + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_MIN_FILTER: + switch(param) { + case GL_LINEAR: + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_BILINEAR; + break; + + case GL_NEAREST: + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NEAREST; + break; + + case GL_FILTER_NONE: /* Compatabile with deprecated kgl */ + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_NONE; + break; + + case GL_FILTER_BILINEAR: /* Compatabile with deprecated kgl */ + GL_TEX_LIST[GL_BOUND_TEX].filter = PVR_FILTER_BILINEAR; + break; + + case GL_NEAREST_MIPMAP_NEAREST: + GL_TEX_LIST[GL_BOUND_TEX].level = PVR_MIPMAP_ENABLE; + break; + + default: + break; + } + + break; + + case GL_TEXTURE_WRAP_S: + switch(param) { + case GL_CLAMP: + GL_CLAMP_ST |= GL_CLAMP_U; + break; + + case GL_REPEAT: + GL_CLAMP_ST ^= GL_CLAMP_U; + break; + } + + break; + + case GL_TEXTURE_WRAP_T: + switch(param) { + case GL_CLAMP: + GL_CLAMP_ST |= GL_CLAMP_V; + break; + + case GL_REPEAT: + GL_CLAMP_ST ^= GL_CLAMP_V; + break; + } + + break; + } + } +} + +void glTexEnvi(GLenum target, GLenum pname, GLint param) { + if(target == GL_TEXTURE_ENV) + if(pname == GL_TEXTURE_ENV_MODE) + if(param >= PVR_TXRENV_REPLACE && param <= PVR_TXRENV_MODULATEALPHA) + GL_TEX_ENV = param; +} + +void glTexEnvf(GLenum target, GLenum pname, GLfloat param) { + /* GL_TEXTURE_LOD_BIAS Not Implemented */ + glTexEnvi(target, pname, param); +} + +GLint gluBuild2DBiMipmaps(GLenum target, GLint internalFormat, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void *data) { + if(target != GL_TEXTURE_2D) + return -1; + + if(width < 1 || height < 1) + return 0; + + uint32 i = 0; + uint16 x , y; + + uint16 *src = (uint16 *)data; + uint16 *dst = (uint16 *)data + (width * height); + + for(y = 0; y < height; y += 2) { + for(x = 0; x < width; x += 2) { + switch(type) { + case GL_UNSIGNED_SHORT_5_6_5: + dst[i++] = __glKosAverageBiPixelRGB565(*src, *(src + 1)); + break; + + case GL_UNSIGNED_SHORT_4_4_4_4: + dst[i++] = __glKosAverageBiPixelARGB4444(*src, *(src + 1)); + break; + + case GL_UNSIGNED_SHORT_1_5_5_5: + dst[i++] = __glKosAverageBiPixelARGB1555(*src, *(src + 1)); + break; + } + + src += 2; + } + + src += width; + } + + return gluBuild2DBiMipmaps(target, internalFormat, width / 2, height / 2, + format, type, (uint16 *)data + (width * height)); +} + +GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, + GLsizei height, GLenum format, GLenum type, const void *data) { + if(target != GL_TEXTURE_2D) + return -1; + + if(width < 1 || height < 1) + return 0; + + if(width == 1 || height == 1) + return gluBuild2DBiMipmaps(target, internalFormat, width, height, format, type, data); + + uint32 i = 0; + uint16 x, y; + + uint16 *src = (uint16 *)data; + uint16 *dst = (uint16 *)data + (width * height); + + for(y = 0; y < height; y += 2) { + for(x = 0; x < width; x += 2) { + switch(type) { + case GL_UNSIGNED_SHORT_5_6_5: + dst[i++] = __glKosAverageQuadPixelRGB565(*src, *(src + 1), *(src + width), *(src + width + 1)); + break; + + case GL_UNSIGNED_SHORT_4_4_4_4: + dst[i++] = __glKosAverageQuadPixelARGB4444(*src, *(src + 1), *(src + width), *(src + width + 1)); + break; + + case GL_UNSIGNED_SHORT_1_5_5_5: + dst[i++] = __glKosAverageQuadPixelARGB1555(*src, *(src + 1), *(src + width), *(src + width + 1)); + break; + } + + src += 2; + } + + src += width; ...<truncated>... hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Lawrence S. <ljs...@us...> - 2014-08-12 02:35:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The KallistiOS port of OpenGL.". The branch, old-libgl has been created at efe60e2ccddd43bde6dd412fcf73843b1239da9d (commit) - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- hooks/post-receive -- The KallistiOS port of OpenGL. |
From: Lawrence S. <ljs...@us...> - 2014-08-12 02:27:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 46bf3f12ec1b9ea1eb5f4321bf81cb75cb594b9f (commit) from ed2a83e146021a5b3ca6732e1f181876c2353754 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 46bf3f12ec1b9ea1eb5f4321bf81cb75cb594b9f Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 11 22:27:03 2014 -0400 A few updates to the SH4 math functions by Josh Pearson. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/fmath.h | 34 +++- kernel/arch/dreamcast/include/dc/fmath_base.h | 23 +++ kernel/arch/dreamcast/include/dc/matrix.h | 2 +- kernel/arch/dreamcast/include/dc/vec3f.h | 259 ++++++++++++++++++++++++- kernel/arch/dreamcast/math/fmath.c | 7 + kernel/arch/dreamcast/math/matrix3d.c | 46 ++--- 6 files changed, 338 insertions(+), 33 deletions(-) diff --git a/kernel/arch/dreamcast/include/dc/fmath.h b/kernel/arch/dreamcast/include/dc/fmath.h index eeb0654..5859ff5 100644 --- a/kernel/arch/dreamcast/include/dc/fmath.h +++ b/kernel/arch/dreamcast/include/dc/fmath.h @@ -2,7 +2,7 @@ dc/fmath.h Copyright (C) 2001 Andrew Kieschnick - Copyright (C) 2013 Lawrence Sebald + Copyright (C) 2013, 2014 Lawrence Sebald */ @@ -16,9 +16,10 @@ __BEGIN_DECLS #include <dc/fmath_base.h> /** - \file dc/fmath.h + \file dc/fmath.h \brief Inline functions for the DC's special math instructions \author Andrew Kieschnick + \author Lawrence Sebald */ /* Sigh... C99 treats inline stuff a lot differently than traditional GCC did, @@ -118,6 +119,32 @@ __FMINLINE float frsqrt(float f) { return __frsqrt(f); } +/** \brief Calculate the sine and cosine of a value in degrees. + + This function uses the fsca instruction to calculate an approximation of the + sine and cosine of the input value. + + \param f The value to calculate the sine and cosine of. + \param s Storage for the returned sine value. + \param c Storage for the returned cosine value. +*/ +__FMINLINE void fsincos(float f, float *s, float *c) { + __fsincos(f, *s, *c); +} + +/** \brief Calculate the sine and cosine of a value in radians. + + This function uses the fsca instruction to calculate an approximation of the + sine and cosine of the input value. + + \param f The value to calculate the sine and cosine of. + \param s Storage for the returned sine value. + \param c Storage for the returned cosine value. +*/ +__FMINLINE void fsincosr(float f, float *s, float *c) { + __fsincosr(f, *s, *c); +} + /* Make sure we declare the non-inline versions for C99 and non-gcc. Why they'd ever be needed, since they're inlined above, who knows? I guess in case someone tries to take the address of one of them? */ @@ -134,10 +161,11 @@ extern float ficos(int d); extern float fitan(int d); extern float fsqrt(float f); extern float frsqrt(float f); +extern void fsincos(float f, float *s, float *c); +extern void fsincosr(float f, float *s, float *c); #endif /* __STDC_VERSION__ >= 199901L || !defined(__GNUC__) */ /** \endcond */ __END_DECLS #endif /* __DC_FMATH_H */ - diff --git a/kernel/arch/dreamcast/include/dc/fmath_base.h b/kernel/arch/dreamcast/include/dc/fmath_base.h index 613f9f3..830c721 100644 --- a/kernel/arch/dreamcast/include/dc/fmath_base.h +++ b/kernel/arch/dreamcast/include/dc/fmath_base.h @@ -2,6 +2,7 @@ dc/fmath_base.h Copyright (C) 2001 Andrew Kieschnick + Copyright (C) 2014 Josh Pearson */ @@ -15,6 +16,7 @@ __BEGIN_DECLS \file dc/fmath_base.h \brief Base definitions for the DC's special math instructions \author Andrew Kieschnick + \author Josh Pearson */ /** PI constant (if you don't want full math.h) */ @@ -87,6 +89,27 @@ __BEGIN_DECLS : "fpul", "fr0", "fr1"); \ __value; }) +#define __fsincos(r, s, c) \ + ({ register float __r __asm__("fr10") = r; \ + register float __a __asm__("fr11") = 182.04444443; \ + __asm__("fmul fr11, fr10\n\t" \ + "ftrc fr10, fpul\n\t" \ + "fsca fpul, dr10\n\t" \ + : "+f" (__r), "+f" (__a) \ + : "0" (__r), "1" (__a) \ + : "fpul"); \ + s = __r; c = __a; }) + +#define __fsincosr(r, s, c) \ + ({ register float __r __asm__("fr10") = r; \ + register float __a __asm__("fr11") = 10430.37835; \ + __asm__("fmul fr11, fr10\n\t" \ + "ftrc fr10, fpul\n\t" \ + "fsca fpul, dr10\n\t" \ + : "+f" (__r), "+f" (__a) \ + : "0" (__r), "1" (__a) \ + : "fpul"); \ + s = __r; c = __a; }) #define __fsqrt(x) \ ({ float __arg = (x); \ diff --git a/kernel/arch/dreamcast/include/dc/matrix.h b/kernel/arch/dreamcast/include/dc/matrix.h index 4abba47..57285ff 100644 --- a/kernel/arch/dreamcast/include/dc/matrix.h +++ b/kernel/arch/dreamcast/include/dc/matrix.h @@ -85,7 +85,7 @@ void mat_transform(vector_t *invecs, vector_t *outvecs, int veccnt, int vecskip) appropriately BEFORE calling this function. \author Jim Ursetto */ -void mat_transform_sq(void * input, void * output, int veccnt); +void mat_transform_sq(void *input, void *output, int veccnt); /** \brief Macro to transform a single vertex by the internal matrix. diff --git a/kernel/arch/dreamcast/include/dc/vec3f.h b/kernel/arch/dreamcast/include/dc/vec3f.h index dc84b21..cc92b11 100644 --- a/kernel/arch/dreamcast/include/dc/vec3f.h +++ b/kernel/arch/dreamcast/include/dc/vec3f.h @@ -22,7 +22,12 @@ #include <sys/cdefs.h> __BEGIN_DECLS -#include <kos/vector.h> +typedef struct vec3f { + float x, y, z; +} vec3f_t; + +#define R_DEG 182.04444443623349541909523793743 +#define R_RAD 10430.37835 /** \brief Macro to return the scalar dot product of two 3d vectors. @@ -175,6 +180,258 @@ __BEGIN_DECLS x3 = __x; y3 = __y; z3 = __z; \ } +/** \brief Macro to rotate a vector about its origin on the x, y plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in radians) of rotation. +*/ +#define vec3f_rotr_xy(px, py, pz, cx, cy, cz, r) { \ + register float __px __asm__("fr0") = px; \ + register float __py __asm__("fr1") = py; \ + register float __cx __asm__("fr4") = cx; \ + register float __cy __asm__("fr5") = cy; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_RAD; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cx), "+f" (__cy) \ + : "f" (__px), "f" (__py), "f" (__r), "f" (__s) ); \ + px = __cx; py = __cy; \ + } + +/** \brief Macro to rotate a vector about its origin on the x, z plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in radians) of rotation. +*/ +#define vec3f_rotr_xz(px, py, pz, cx, cy, cz, r) { \ + register float __px __asm__("fr0") = px; \ + register float __pz __asm__("fr1") = pz; \ + register float __cx __asm__("fr4") = cx; \ + register float __cz __asm__("fr5") = cz; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_RAD; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cx), "+f" (__cz) \ + : "f" (__px), "f" (__pz), "f" (__r), "f" (__s) ); \ + px = __cx; pz = __cz; \ + } + +/** \brief Macro to rotate a vector about its origin on the y, z plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in radians) of rotation. +*/ +#define vec3f_rotr_yz(px, py, pz, cx, cy, cz, r) { \ + register float __py __asm__("fr0") = py; \ + register float __pz __asm__("fr1") = pz; \ + register float __cy __asm__("fr4") = cy; \ + register float __cz __asm__("fr5") = cz; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_RAD; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cy), "+f" (__cz) \ + : "f" (__py), "f" (__pz), "f" (__r), "f" (__s) ); \ + py = __cy; pz = __cz; \ + } + +/** \brief Macro to rotate a vector about its origin on the x, y plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in degrees) of rotation. +*/ +#define vec3f_rotd_xy(px, py, pz, cx, cy, cz, r) { \ + register float __px __asm__("fr0") = px; \ + register float __pz __asm__("fr1") = pz; \ + register float __cx __asm__("fr4") = cx; \ + register float __cz __asm__("fr5") = cz; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_DEG; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cx), "+f" (__cz) \ + : "f" (__px), "f" (__pz), "f" (__r), "f" (__s) ); \ + px = __cx; pz = __cz; \ + } + +/** \brief Macro to rotate a vector about its origin on the x, z plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in degrees) of rotation. +*/ +#define vec3f_rotd_xz(px, py, pz, cx, cy, cz, r) { \ + register float __px __asm__("fr0") = px; \ + register float __pz __asm__("fr1") = pz; \ + register float __cx __asm__("fr4") = cx; \ + register float __cz __asm__("fr5") = cz; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_DEG; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cx), "+f" (__cz) \ + : "f" (__px), "f" (__pz), "f" (__r), "f" (__s) ); \ + px = __cx; pz = __cz; \ + } + +/** \brief Macro to rotate a vector about its origin on the y, z plane. + + This macro is an inline assembly operation using the SH4's fast + (approximate) math instructions. The return vector is stored into the first + vertex parameter: x1, y1, and z1. + + \param px The X coordinate of vector to rotate. + \param py The Y coordinate of vector to rotate. + \param pz The Z coordinate of vector to rotate. + \param cx The X coordinate of origin vector. + \param cy The Y coordinate of origin vector. + \param cz The Z coordinate of origin vector. + \param r The angle (in degrees) of rotation. +*/ +#define vec3f_rotd_yz(px, py, pz, cx, cy, cz, r) { \ + register float __py __asm__("fr0") = py; \ + register float __pz __asm__("fr1") = pz; \ + register float __cy __asm__("fr4") = cy; \ + register float __cz __asm__("fr5") = cz; \ + register float __r __asm__("fr6") = r; \ + register float __s __asm__("fr7") = R_DEG; \ + __asm__ __volatile__( \ + "fmul fr7, fr6\n" \ + "ftrc fr6, fpul\n" \ + "fsca fpul, dr6\n" \ + "fsub fr4, fr0\n" \ + "fsub fr5, fr1\n" \ + "fmov fr0, fr2\n" \ + "fmov fr1, fr3\n" \ + "fmul fr7, fr0\n" \ + "fmul fr6, fr1\n" \ + "fmul fr6, fr2\n" \ + "fmul fr7, fr3\n" \ + "fadd fr0, fr4\n" \ + "fsub fr1, fr4\n" \ + "fadd fr2, fr5\n" \ + "fadd fr3, fr5\n" \ + : "+f" (__cy), "+f" (__cz) \ + : "f" (__py), "f" (__pz), "f" (__r), "f" (__s) ); \ + py = __cy; pz = __cz; \ + } + __END_DECLS #endif /* !__DC_VEC3F_H */ diff --git a/kernel/arch/dreamcast/math/fmath.c b/kernel/arch/dreamcast/math/fmath.c index 872603a..8e61816 100644 --- a/kernel/arch/dreamcast/math/fmath.c +++ b/kernel/arch/dreamcast/math/fmath.c @@ -57,3 +57,10 @@ float frsqrt(float f) { return __frsqrt(f); } +void fsincos(float f, float *s, float *c) { + __fsincos(f, *s, *c); +} + +void fsincosr(float f, float *s, float *c) { + __fsincosr(f, *s, *c); +} diff --git a/kernel/arch/dreamcast/math/matrix3d.c b/kernel/arch/dreamcast/math/matrix3d.c index 73eeaaf..9200163 100644 --- a/kernel/arch/dreamcast/math/matrix3d.c +++ b/kernel/arch/dreamcast/math/matrix3d.c @@ -1,7 +1,8 @@ /* KallistiOS ##version## matrix3d.c - (c)2000-2002 Dan Potter and Jordan DeLong + Copyright (C) 2000-2002 Dan Potter and Jordan DeLong + Copyright (C) 2014 Josh Pearson Some 3D utils to use with the matrix functions Based on example code by Marcus Comstedt @@ -11,6 +12,7 @@ #include <dc/fmath.h> #include <dc/matrix.h> #include <dc/matrix3d.h> +#include <dc/vec3f.h> static matrix_t tr_m __attribute__((aligned(32))) = { { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -45,9 +47,9 @@ static matrix_t rx_m __attribute__((aligned(32))) = { { 0.0f, 0.0f, 0.0f, 1.0f } }; void mat_rotate_x(float r) { - rx_m[1][1] = rx_m[2][2] = fcos(r); - rx_m[2][1] = fsin(r); - rx_m[1][2] = -fsin(r); + __fsincosr(r, rx_m[2][1], rx_m[1][1]); + rx_m[2][2] = rx_m[1][1]; + rx_m[1][2] = -rx_m[2][1]; mat_apply(&rx_m); } @@ -58,9 +60,9 @@ static matrix_t ry_m __attribute__((aligned(32))) = { { 0.0f, 0.0f, 0.0f, 1.0f } }; void mat_rotate_y(float r) { - ry_m[0][0] = ry_m[2][2] = fcos(r); - ry_m[2][0] = -fsin(r); - ry_m[0][2] = fsin(r); + __fsincosr(r, ry_m[0][2], ry_m[0][0]); + ry_m[2][2] = ry_m[0][0]; + ry_m[2][0] = -ry_m[0][2]; mat_apply(&ry_m); } @@ -71,9 +73,9 @@ static matrix_t rz_m __attribute__((aligned(32))) = { { 0.0f, 0.0f, 0.0f, 1.0f } }; void mat_rotate_z(float r) { - rz_m[0][0] = rz_m[1][1] = fcos(r); - rz_m[1][0] = fsin(r); - rz_m[0][1] = -fsin(r); + __fsincosr(r, rz_m[1][0], rz_m[0][0]); + rz_m[1][1] = rz_m[0][0]; + rz_m[0][1] = -rz_m[1][0]; mat_apply(&rz_m); } @@ -124,20 +126,7 @@ void mat_perspective(float xcenter, float ycenter, float cot_fovy_2, /* The following lookat code is based heavily on KGL's gluLookAt */ -/* Should these be publically accessible somewhere? */ -static void normalize(vector_t * p) { - float r; - - r = fsqrt(p->x * p->x + p->y * p->y + p->z * p->z); - - if(r == 0.0) return; - - p->x /= r; - p->y /= r; - p->z /= r; -} - -static void cross(const vector_t * v1, const vector_t * v2, vector_t * r) { +static void cross(const vec3f_t *v1, const vec3f_t *v2, vec3f_t *r) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-06-13 23:18:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via ed2a83e146021a5b3ca6732e1f181876c2353754 (commit) from 5e6026791b51e4ed17d69ca69ac8c60c50a03c82 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ed2a83e146021a5b3ca6732e1f181876c2353754 Author: Lawrence Sebald <ljs...@us...> Date: Fri Jun 13 19:18:32 2014 -0400 Add new dns-client network example that uses the getaddrinfo() function. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/network/Makefile | 3 + .../network/{udpecho6 => dns-client}/Makefile | 13 +-- examples/dreamcast/network/dns-client/dns-client.c | 114 ++++++++++++++++++++ 3 files changed, 120 insertions(+), 10 deletions(-) copy examples/dreamcast/network/{udpecho6 => dns-client}/Makefile (62%) create mode 100644 examples/dreamcast/network/dns-client/dns-client.c diff --git a/examples/dreamcast/network/Makefile b/examples/dreamcast/network/Makefile index bc15bae..d2581dd 100644 --- a/examples/dreamcast/network/Makefile +++ b/examples/dreamcast/network/Makefile @@ -9,15 +9,18 @@ all: $(KOS_MAKE) -C ping $(KOS_MAKE) -C ping6 $(KOS_MAKE) -C udpecho6 + $(KOS_MAKE) -C dns-client clean: $(KOS_MAKE) -C basic clean $(KOS_MAKE) -C ping clean $(KOS_MAKE) -C ping6 clean $(KOS_MAKE) -C udpecho6 clean + $(KOS_MAKE) -C dns-client clean dist: $(KOS_MAKE) -C basic dist $(KOS_MAKE) -C ping dist $(KOS_MAKE) -C ping6 dist $(KOS_MAKE) -C udpecho6 dist + $(KOS_MAKE) -C dns-client dist diff --git a/examples/dreamcast/network/udpecho6/Makefile b/examples/dreamcast/network/dns-client/Makefile similarity index 62% copy from examples/dreamcast/network/udpecho6/Makefile copy to examples/dreamcast/network/dns-client/Makefile index f233206..adfe504 100644 --- a/examples/dreamcast/network/udpecho6/Makefile +++ b/examples/dreamcast/network/dns-client/Makefile @@ -1,13 +1,8 @@ -# -# Basic KallistiOS skeleton / test program -# (c)2001 Dan Potter -# - # Put the filename of the output binary here -TARGET = echo.elf +TARGET = dns-client.elf # List all of your C files here, but change the extension to ".o" -OBJS = echo.o +OBJS = dns-client.o all: rm-elf $(TARGET) @@ -20,8 +15,7 @@ rm-elf: -rm -f $(TARGET) $(TARGET): $(OBJS) - $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \ - $(OBJS) $(OBJEXTRA) $(KOS_LIBS) + kos-cc -o $(TARGET) $(OBJS) run: $(TARGET) $(KOS_LOADER) $(TARGET) -n @@ -29,4 +23,3 @@ run: $(TARGET) dist: rm -f $(OBJS) $(KOS_STRIP) $(TARGET) - diff --git a/examples/dreamcast/network/dns-client/dns-client.c b/examples/dreamcast/network/dns-client/dns-client.c new file mode 100644 index 0000000..e9d048e --- /dev/null +++ b/examples/dreamcast/network/dns-client/dns-client.c @@ -0,0 +1,114 @@ +/* KallistiOS ##version## + + dns-client.c + Copyright (C) 2014 Lawrence Sebald + + This example demonstrates how to use getaddrinfo() to look up the network + address for a given hostname. + + This example also shows how to display things on the framebuffer with the + "fb" device for dbgio. + +*/ + +#include <stdio.h> +#include <string.h> + +#include <netdb.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <netinet/in.h> + +#include <kos/net.h> +#include <kos/dbgio.h> +#include <arch/arch.h> + +KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET); + +static void print_addrinfo(struct addrinfo *ai) { + struct addrinfo *p; + char str[INET6_ADDRSTRLEN]; + struct sockaddr_in *addr4; + struct sockaddr_in6 *addr6; + void *addr; + int i; + + /* Go through each result in the chain and print out the address that it + contains. */ + for(p = ai, i = 0; p; p = p->ai_next, ++i) { + if(p->ai_family == AF_INET) { + addr4 = (struct sockaddr_in *)p->ai_addr; + addr = &addr4->sin_addr; + } + else if(p->ai_family == AF_INET6) { + addr6 = (struct sockaddr_in6 *)p->ai_addr; + addr = &addr6->sin6_addr; + } + else { + /* Shouldn't ever end up here... */ + continue; + } + + /* Convert the raw address to a string. */ + inet_ntop(p->ai_family, addr, str, INET6_ADDRSTRLEN); + printf("%d: %s\n", i, str); + } +} + + +int main(int argc, char *argv[]) { + struct addrinfo *ai; + struct addrinfo hints; + int err; + + /* Set the framebuffer as the output device for dbgio. */ + dbgio_dev_select("fb"); + + /* Check if the default network device has a DNS server set, and set one if + it does not for some reason. We'll set up 8.8.4.4 as the DNS server, + which is one of Google's Public DNS servers. */ + if(!net_default_dev->dns[0]) { + net_default_dev->dns[0] = 8; + net_default_dev->dns[1] = 8; + net_default_dev->dns[2] = 4; + net_default_dev->dns[3] = 4; + } + + /* First request just the IPv4 address of something. */ + printf("Looking up IPv4 address of sylverant.net\n"); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + + if((err = getaddrinfo("sylverant.net", NULL, &hints, &ai))) { + printf("Error looking up IPv4 address information: %d\n", err); + } + + /* Print out each result, then clean it up. */ + print_addrinfo(ai); + freeaddrinfo(ai); + + /* Now, request the IPv6 address of the same thing. Note, we could (and + really should) have done both at the same time. But, this is an example, + so I figured I should show both ways. */ + printf("Looking up IPv6 address of sylverant.net\n"); + hints.ai_family = AF_INET6; + + if((err = getaddrinfo("sylverant.net", NULL, &hints, &ai))) { + printf("Error looking up IPv6 address information: %d\n", err); + } + + /* Print out each result, then clean it up. */ + print_addrinfo(ai); + freeaddrinfo(ai); + + /* If you want to look up both IPv4 and IPv6 at the same time, either set + hints.ai_family to AF_UNSPEC, or (if you aren't using any of the other + parts of the hints structure) pass NULL instead of a pointer to the hints + structure. */ + + /* Wait 10 seconds for the user to see what's on the screen before we clear + it during the exit back to the loader */ + thd_sleep(10 * 1000); + + return 0; +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-06-13 22:49:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 5e6026791b51e4ed17d69ca69ac8c60c50a03c82 (commit) from 5cd0fd3fdf1ca507b576e60f56dedc890f21db3d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5e6026791b51e4ed17d69ca69ac8c60c50a03c82 Author: Lawrence Sebald <ljs...@us...> Date: Fri Jun 13 18:46:38 2014 -0400 Move the lwIP examples out of the network examples directory and into their own. Other than dcload-ip-lwip-test, all of these could easily be modified to not use lwIP, and they will be sometime soon. Also, I'm considering removing lwIP entirely sometime. Probably won't do it until after the next release, though. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/lwip/Makefile | 19 +++++++++++++++++++ .../{network => lwip}/dcload-ip-lwip-test/Makefile | 0 .../{network => lwip}/dcload-ip-lwip-test/main.c | 0 .../{network => lwip}/dns-client/Makefile | 0 .../{network => lwip}/dns-client/dnslookup.c | 0 .../dreamcast/{network => lwip}/httpd/Makefile | 0 examples/dreamcast/{network => lwip}/httpd/httpd.c | 0 .../{network => lwip}/httpd/romdisk/changelog.html | 0 .../httpd/romdisk/documentation.html | 0 .../{network => lwip}/httpd/romdisk/download.html | 0 .../{network => lwip}/httpd/romdisk/img/sics.gif | Bin 724 -> 724 bytes .../{network => lwip}/httpd/romdisk/index.html | 0 .../{network => lwip}/httpd/romdisk/licence.html | 0 .../{network => lwip}/httpd/romdisk/links.html | 0 .../httpd/romdisk/mailinglist.html | 0 .../{network => lwip}/httpd/romdisk/news.html | 0 .../dreamcast/{network => lwip}/httpd/simhost.c | 0 examples/dreamcast/network/Makefile | 8 -------- 18 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 examples/dreamcast/lwip/Makefile rename examples/dreamcast/{network => lwip}/dcload-ip-lwip-test/Makefile (100%) rename examples/dreamcast/{network => lwip}/dcload-ip-lwip-test/main.c (100%) rename examples/dreamcast/{network => lwip}/dns-client/Makefile (100%) rename examples/dreamcast/{network => lwip}/dns-client/dnslookup.c (100%) rename examples/dreamcast/{network => lwip}/httpd/Makefile (100%) rename examples/dreamcast/{network => lwip}/httpd/httpd.c (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/changelog.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/documentation.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/download.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/img/sics.gif (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/index.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/licence.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/links.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/mailinglist.html (100%) rename examples/dreamcast/{network => lwip}/httpd/romdisk/news.html (100%) rename examples/dreamcast/{network => lwip}/httpd/simhost.c (100%) diff --git a/examples/dreamcast/lwip/Makefile b/examples/dreamcast/lwip/Makefile new file mode 100644 index 0000000..8fd5b87 --- /dev/null +++ b/examples/dreamcast/lwip/Makefile @@ -0,0 +1,19 @@ +# KallistiOS ##version## +# +# examples/dreamcast/lwip/Makefile +# + +all: + $(KOS_MAKE) -C dns-client + $(KOS_MAKE) -C httpd +# $(KOS_MAKE) -C dcload-ip-lwip-test + +clean: + $(KOS_MAKE) -C dns-client clean + $(KOS_MAKE) -C httpd clean +# $(KOS_MAKE) -C dcload-ip-lwip-test clean + +dist: + $(KOS_MAKE) -C dns-client dist + $(KOS_MAKE) -C httpd dist +# $(KOS_MAKE) -C dcload-ip-lwip-test dist diff --git a/examples/dreamcast/network/dcload-ip-lwip-test/Makefile b/examples/dreamcast/lwip/dcload-ip-lwip-test/Makefile similarity index 100% rename from examples/dreamcast/network/dcload-ip-lwip-test/Makefile rename to examples/dreamcast/lwip/dcload-ip-lwip-test/Makefile diff --git a/examples/dreamcast/network/dcload-ip-lwip-test/main.c b/examples/dreamcast/lwip/dcload-ip-lwip-test/main.c similarity index 100% rename from examples/dreamcast/network/dcload-ip-lwip-test/main.c rename to examples/dreamcast/lwip/dcload-ip-lwip-test/main.c diff --git a/examples/dreamcast/network/dns-client/Makefile b/examples/dreamcast/lwip/dns-client/Makefile similarity index 100% rename from examples/dreamcast/network/dns-client/Makefile rename to examples/dreamcast/lwip/dns-client/Makefile diff --git a/examples/dreamcast/network/dns-client/dnslookup.c b/examples/dreamcast/lwip/dns-client/dnslookup.c similarity index 100% rename from examples/dreamcast/network/dns-client/dnslookup.c rename to examples/dreamcast/lwip/dns-client/dnslookup.c diff --git a/examples/dreamcast/network/httpd/Makefile b/examples/dreamcast/lwip/httpd/Makefile similarity index 100% rename from examples/dreamcast/network/httpd/Makefile rename to examples/dreamcast/lwip/httpd/Makefile diff --git a/examples/dreamcast/network/httpd/httpd.c b/examples/dreamcast/lwip/httpd/httpd.c similarity index 100% rename from examples/dreamcast/network/httpd/httpd.c rename to examples/dreamcast/lwip/httpd/httpd.c diff --git a/examples/dreamcast/network/httpd/romdisk/changelog.html b/examples/dreamcast/lwip/httpd/romdisk/changelog.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/changelog.html rename to examples/dreamcast/lwip/httpd/romdisk/changelog.html diff --git a/examples/dreamcast/network/httpd/romdisk/documentation.html b/examples/dreamcast/lwip/httpd/romdisk/documentation.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/documentation.html rename to examples/dreamcast/lwip/httpd/romdisk/documentation.html diff --git a/examples/dreamcast/network/httpd/romdisk/download.html b/examples/dreamcast/lwip/httpd/romdisk/download.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/download.html rename to examples/dreamcast/lwip/httpd/romdisk/download.html diff --git a/examples/dreamcast/network/httpd/romdisk/index.html b/examples/dreamcast/lwip/httpd/romdisk/index.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/index.html rename to examples/dreamcast/lwip/httpd/romdisk/index.html diff --git a/examples/dreamcast/network/httpd/romdisk/licence.html b/examples/dreamcast/lwip/httpd/romdisk/licence.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/licence.html rename to examples/dreamcast/lwip/httpd/romdisk/licence.html diff --git a/examples/dreamcast/network/httpd/romdisk/links.html b/examples/dreamcast/lwip/httpd/romdisk/links.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/links.html rename to examples/dreamcast/lwip/httpd/romdisk/links.html diff --git a/examples/dreamcast/network/httpd/romdisk/mailinglist.html b/examples/dreamcast/lwip/httpd/romdisk/mailinglist.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/mailinglist.html rename to examples/dreamcast/lwip/httpd/romdisk/mailinglist.html diff --git a/examples/dreamcast/network/httpd/romdisk/news.html b/examples/dreamcast/lwip/httpd/romdisk/news.html similarity index 100% rename from examples/dreamcast/network/httpd/romdisk/news.html rename to examples/dreamcast/lwip/httpd/romdisk/news.html diff --git a/examples/dreamcast/network/httpd/simhost.c b/examples/dreamcast/lwip/httpd/simhost.c similarity index 100% rename from examples/dreamcast/network/httpd/simhost.c rename to examples/dreamcast/lwip/httpd/simhost.c diff --git a/examples/dreamcast/network/Makefile b/examples/dreamcast/network/Makefile index 6dd685d..bc15bae 100644 --- a/examples/dreamcast/network/Makefile +++ b/examples/dreamcast/network/Makefile @@ -6,26 +6,18 @@ all: $(KOS_MAKE) -C basic - $(KOS_MAKE) -C httpd $(KOS_MAKE) -C ping $(KOS_MAKE) -C ping6 $(KOS_MAKE) -C udpecho6 -# $(KOS_MAKE) -C dcload-ip-lwip-test clean: $(KOS_MAKE) -C basic clean - $(KOS_MAKE) -C httpd clean $(KOS_MAKE) -C ping clean $(KOS_MAKE) -C ping6 clean $(KOS_MAKE) -C udpecho6 clean -# $(KOS_MAKE) -C dcload-ip-lwip-test clean dist: $(KOS_MAKE) -C basic dist - $(KOS_MAKE) -C httpd dist $(KOS_MAKE) -C ping dist $(KOS_MAKE) -C ping6 dist $(KOS_MAKE) -C udpecho6 dist -# $(KOS_MAKE) -C dcload-ip-lwip-test dist - - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: Lawrence S. <ljs...@us...> - 2014-06-11 01:48:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 5cd0fd3fdf1ca507b576e60f56dedc890f21db3d (commit) from 72c5ac86fbdf2199d8912135f548a3e3210b0135 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5cd0fd3fdf1ca507b576e60f56dedc890f21db3d Author: Lawrence Sebald <ljs...@us...> Date: Tue Jun 10 21:47:09 2014 -0400 Have getaddrinfo() make multiple attempts to contact the server and time out after failing a few times. For now, the timeout between attempts is 500 ms and it tries 4 times. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 4 ++- kernel/libc/koslib/getaddrinfo.c | 49 +++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 910a04c..abd4a07 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -42,7 +42,9 @@ KallistiOS version 2.0.1 ----------------------------------------------- - DC Added many new matrix/vector math-related macros [Josh Pearson = JP] - *** Added libppp for dialup internet access to the addons tree [LS] - *** Added DNS resolver functions getaddrinfo() and gethostbyname() [LS] -- *** Fix a problem where poll() would deadlock if the timeout expired [LS] +- *** Fixed a problem where poll() would deadlock if the timeout expired [LS] +- *** Modified getaddrinfo() so that it would try multiple times to contact the + DNS server with a timeout between messages [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/kernel/libc/koslib/getaddrinfo.c b/kernel/libc/koslib/getaddrinfo.c index 7f52e8b..9685203 100644 --- a/kernel/libc/koslib/getaddrinfo.c +++ b/kernel/libc/koslib/getaddrinfo.c @@ -28,7 +28,7 @@ #include <string.h> #include <stdlib.h> #include <errno.h> -#include <kos/dbglog.h> +#include <poll.h> #include <netdb.h> #include <sys/socket.h> @@ -36,8 +36,13 @@ #include <netinet/in.h> #include <kos/net.h> +#include <kos/dbglog.h> -#define printf(...) dbglog(DBG_KDEBUG, __VA_ARGS__); +/* How many attempts to make at contacting the DNS server before giving up. */ +#define DNS_ATTEMPTS 4 + +/* How long to wait between attempts. */ +#define DNS_TIMEOUT 500 /* This performs a simple DNS A-record query. It hasn't been tested extensively @@ -411,9 +416,10 @@ static int getaddrinfo_dns(const char *name, struct addrinfo *hints, struct sockaddr_in toaddr; uint8_t qb[512]; size_t size; - int sock, rv; + int sock, rv, tries; in_addr_t raddr; - ssize_t rsize; + ssize_t rsize = 0; + struct pollfd pfd; /* Make sure we have a network device to communicate on. */ if(!net_default_dev) { @@ -462,19 +468,40 @@ static int getaddrinfo_dns(const char *name, struct addrinfo *hints, return EAI_SYSTEM; } - /* Send the query to the server. */ - if(send(sock, qb, size, 0) < 0) { - return EAI_SYSTEM; - } + /* Set up the structure we'll use to feed to the poll function. */ + pfd.fd = sock; + pfd.events = POLLIN; + pfd.revents = 0; - /* Get the response. */ - if((rsize = recv(sock, qb, 512, 0)) < 0) { - return EAI_SYSTEM; + for(tries = 0; tries < DNS_ATTEMPTS; ++tries) { + /* Send the query to the server. */ + if(send(sock, qb, size, 0) < 0) { + return EAI_SYSTEM; + } + + /* Wait for the timeout to expire or for us to get the response. */ + if(poll(&pfd, 1, DNS_TIMEOUT) == 1) { + /* Get the response. */ + if((rsize = recv(sock, qb, 512, 0)) < 0) { + return EAI_SYSTEM; + } + + break; + } } /* Close the socket */ close(sock); + /* If we never actually got a response, then there's probably a problem with + the server on the other end. I'm not entirely sure what to return in that + case, to be perfectly honest. I suppose that EAI_SYSTEM + ETIMEDOUT would + make the most sense, since that's really what happened... */ + if(!rsize) { + errno = ETIMEDOUT; + return EAI_SYSTEM; + } + /* Parse the response. */ rv = dns_parse_response((dnsmsg_t *)qb, hints, port, res); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |