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
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ljs...@us...> - 2009-06-06 14:16:08
|
Revision: 642 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=642&view=rev Author: ljsebald Date: 2009-06-06 14:15:37 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Wait on an object that actually will exist when the DHCP request is fulfilled. Modified Paths: -------------- kos/kernel/net/net_dhcp.c Modified: kos/kernel/net/net_dhcp.c =================================================================== --- kos/kernel/net/net_dhcp.c 2009-06-06 04:41:23 UTC (rev 641) +++ kos/kernel/net/net_dhcp.c 2009-06-06 14:15:37 UTC (rev 642) @@ -266,7 +266,7 @@ /* We need to wait til we're either bound to an IP address, or until we give up all hope of doing so (give us 60 seconds). */ if(thd_current != dhcp_thd) { - rv = genwait_wait(qpkt, "net_dhcp_request", 60 * 1000, NULL); + rv = genwait_wait(&dhcp_sock, "net_dhcp_request", 60 * 1000, NULL); } return rv; @@ -575,7 +575,7 @@ /* Bind to the specified IP address */ net_dhcp_bind(pkt, len); - genwait_wake_all(qpkt); + genwait_wake_all(&dhcp_sock); } else if(found == DHCP_MSG_DHCPNAK) { /* We got a NAK, try to discover again. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-06-06 04:41:24
|
Revision: 641 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=641&view=rev Author: ljsebald Date: 2009-06-06 04:41:23 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Add the MTU of the interface to the netif structure and some fixups for DHCP. Modified Paths: -------------- kos/include/kos/net.h kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c kos/kernel/net/net_dhcp.c Modified: kos/include/kos/net.h =================================================================== --- kos/include/kos/net.h 2009-06-05 02:02:22 UTC (rev 640) +++ kos/include/kos/net.h 2009-06-06 04:41:23 UTC (rev 641) @@ -48,15 +48,21 @@ /* The device's IP address (if any) */ uint8 ip_addr[4]; - /* The device's netmask */ - uint8 netmask[4]; + /* The device's netmask */ + uint8 netmask[4]; - /* The device's gateway's IP address */ - uint8 gateway[4]; + /* The device's gateway's IP address */ + uint8 gateway[4]; - /* The device's broadcast address */ - uint8 broadcast[4]; + /* The device's broadcast address */ + uint8 broadcast[4]; + /* The device's DNS server address */ + uint8 dns[4]; + + /* The interface's MTU */ + int mtu; + /* All of the following callback functions should return a negative value on failure, and a zero or positive value on success. Some functions have special values, as noted. */ Modified: kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2009-06-05 02:02:22 UTC (rev 640) +++ kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2009-06-06 04:41:23 UTC (rev 641) @@ -1047,6 +1047,8 @@ memset(bba_if.netmask, 0, sizeof(bba_if.netmask)); memset(bba_if.gateway, 0, sizeof(bba_if.gateway)); memset(bba_if.broadcast, 0, sizeof(bba_if.broadcast)); + memset(bba_if.dns, 0, sizeof(bba_if.dns)); + bba_if.mtu = 1500; /* The Ethernet v2 MTU */ bba_if.if_detect = bba_if_detect; bba_if.if_init = bba_if_init; bba_if.if_shutdown = bba_if_shutdown; Modified: kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c 2009-06-05 02:02:22 UTC (rev 640) +++ kos/kernel/arch/dreamcast/hardware/network/lan_adapter.c 2009-06-06 04:41:23 UTC (rev 641) @@ -661,12 +661,14 @@ la_if.name = "la"; la_if.descr = "Lan Adapter (HIT-0300)"; la_if.index = 0; - la_if.dev_id =0 ; + la_if.dev_id = 0 ; la_if.flags = NETIF_NO_FLAGS; memset(la_if.ip_addr, 0, sizeof(la_if.ip_addr)); memset(la_if.netmask, 0, sizeof(la_if.netmask)); memset(la_if.gateway, 0, sizeof(la_if.gateway)); memset(la_if.broadcast, 0, sizeof(la_if.broadcast)); + memset(la_if.dns, 0, sizeof(la_if.dns)); + la_if.mtu = 1500; /* The Ethernet v2 MTU */ la_if.if_detect = la_if_detect; la_if.if_init = la_if_init; la_if.if_shutdown = la_if_shutdown; Modified: kos/kernel/net/net_dhcp.c =================================================================== --- kos/kernel/net/net_dhcp.c 2009-06-05 02:02:22 UTC (rev 640) +++ kos/kernel/net/net_dhcp.c 2009-06-06 04:41:23 UTC (rev 641) @@ -1,7 +1,7 @@ /* KallistiOS ##version## kernel/net/net_dhcp.c - Copyright (C) 2008 Lawrence Sebald + Copyright (C) 2008, 2009 Lawrence Sebald */ @@ -60,44 +60,39 @@ req->options[pos++] = 0x82; req->options[pos++] = 0x53; req->options[pos++] = 0x63; - + /* Message Type: DHCPDISCOVER */ req->options[pos++] = DHCP_OPTION_MESSAGE_TYPE; req->options[pos++] = 1; /* Length = 1 */ req->options[pos++] = msgtype; - - req->options[pos++] = DHCP_OPTION_PAD; /* Pad for alignment */ - - /* Max Message Length: 1024 octets */ + + /* Max Message Length: 1500 octets */ req->options[pos++] = DHCP_OPTION_MAX_MESSAGE; req->options[pos++] = 2; /* Length = 2 */ - *((uint16 *)(req->options + pos)) = htons(1024); - pos += 2; - + req->options[pos++] = (net->mtu >> 8) & 0xFF; + req->options[pos++] = (net->mtu >> 0) & 0xFF; + /* Host Name: Dreamcast */ req->options[pos++] = DHCP_OPTION_HOST_NAME; req->options[pos++] = 10; /* Length = 10 */ strcpy((char *)req->options + pos, "KallistiOS"); pos += 10; - + /* Client Identifier: The network adapter's MAC address */ req->options[pos++] = DHCP_OPTION_CLIENT_ID; req->options[pos++] = 1 + DHCP_HLEN_ETHERNET; /* Length = 7 */ req->options[pos++] = DHCP_HTYPE_10MB_ETHERNET; memcpy(req->options + pos, net->mac_addr, DHCP_HLEN_ETHERNET); pos += DHCP_HLEN_ETHERNET; - - req->options[pos++] = DHCP_OPTION_PAD; /* Pad for alignment */ - req->options[pos++] = DHCP_OPTION_PAD; - req->options[pos++] = DHCP_OPTION_PAD; - - /* Parameters requested: Subnet, Router, DNS, Broadcast */ + + /* Parameters requested: Subnet, Router, DNS, Broadcast, MTU */ req->options[pos++] = DHCP_OPTION_PARAMETER_REQUEST; - req->options[pos++] = 4; /* Length = 4 */ + req->options[pos++] = 5; /* Length = 5 */ req->options[pos++] = DHCP_OPTION_SUBNET_MASK; req->options[pos++] = DHCP_OPTION_ROUTER; req->options[pos++] = DHCP_OPTION_DOMAIN_NAME_SERVER; req->options[pos++] = DHCP_OPTION_BROADCAST_ADDR; + req->options[pos++] = DHCP_OPTION_INTERFACE_MTU; if(serverid) { /* Add the Server identifier option */ @@ -119,9 +114,6 @@ req->options[pos++] = (reqip >> 0) & 0xFF; } - /* Pad so that we have an even number of octets */ - req->options[pos++] = DHCP_OPTION_PAD; - /* The End */ req->options[pos++] = DHCP_OPTION_END; @@ -144,7 +136,7 @@ ++i; } else { - i += pkt->options[i + 1]; + i += pkt->options[i + 1] + 2; } } @@ -163,24 +155,50 @@ return (pkt->options[i + 2] << 24) | (pkt->options[i + 3] << 16) | (pkt->options[i + 4] << 8) | (pkt->options[i + 5]); } - else if(pkt->options[i] == DHCP_OPTION_PAD || - pkt->options[i] == DHCP_OPTION_END) { + else if(pkt->options[i] == DHCP_OPTION_PAD) { ++i; } + else if(pkt->options[i] == DHCP_OPTION_END) { + break; + } else { - i += pkt->options[i + 1]; + i += pkt->options[i + 1] + 2; } } return 0; } +static uint16 net_dhcp_get_16bit(dhcp_pkt_t *pkt, uint8 opt, int len) { + int i; + + len -= sizeof(dhcp_pkt_t); + + /* Read each byte of the options field looking for the specified option, + return it when found. */ + for(i = 4; i < len;) { + if(pkt->options[i] == opt) { + return (pkt->options[i + 2] << 8) | (pkt->options[i + 3]); + } + else if(pkt->options[i] == DHCP_OPTION_PAD) { + ++i; + } + else if(pkt->options[i] == DHCP_OPTION_END) { + break; + } + else { + i += pkt->options[i + 1] + 2; + } + } + + return 0; +} + int net_dhcp_request() { - uint8 pkt[1024]; + uint8 pkt[1500]; dhcp_pkt_t *req = (dhcp_pkt_t *)pkt; int optlen; struct dhcp_pkt_out *qpkt; - uint32 old; int rv = 0; if(dhcp_sock == -1) { @@ -243,25 +261,20 @@ STAILQ_INSERT_TAIL(&dhcp_pkts, qpkt, pkt_queue); state = DHCP_STATE_SELECTING; - - old = irq_disable(); rlock_unlock(dhcp_lock); /* We need to wait til we're either bound to an IP address, or until we give up all hope of doing so (give us 60 seconds). */ - if(thd_current != dhcp_thd) { rv = genwait_wait(qpkt, "net_dhcp_request", 60 * 1000, NULL); } - irq_restore(old); - return rv; } static void net_dhcp_send_request(dhcp_pkt_t *pkt, int pktlen, dhcp_pkt_t *pkt2, int pkt2len) { - uint8 buf[1024]; + uint8 buf[1500]; dhcp_pkt_t *req = (dhcp_pkt_t *)buf; int optlen; struct dhcp_pkt_out *qpkt; @@ -318,7 +331,7 @@ } static void net_dhcp_renew() { - uint8 buf[1024]; + uint8 buf[1500]; dhcp_pkt_t *req = (dhcp_pkt_t *)buf; int optlen; struct dhcp_pkt_out *qpkt; @@ -399,13 +412,13 @@ } /* Grab the DNS address if it was returned to us */ - tmp = net_dhcp_get_32bit(pkt, DHCP_OPTION_NAME_SERVER, len); + tmp = net_dhcp_get_32bit(pkt, DHCP_OPTION_DOMAIN_NAME_SERVER, len); if(tmp != 0) { - net_default_dev->gateway[0] = (tmp >> 24) & 0xFF; - net_default_dev->gateway[1] = (tmp >> 16) & 0xFF; - net_default_dev->gateway[2] = (tmp >> 8) & 0xFF; - net_default_dev->gateway[3] = (tmp >> 0) & 0xFF; + net_default_dev->dns[0] = (tmp >> 24) & 0xFF; + net_default_dev->dns[1] = (tmp >> 16) & 0xFF; + net_default_dev->dns[2] = (tmp >> 8) & 0xFF; + net_default_dev->dns[3] = (tmp >> 0) & 0xFF; } /* Grab the broadcast address if it was sent to us, otherwise infer it from @@ -446,6 +459,13 @@ renew_time = rebind_time = lease_expires = 0xFFFFFFFFFFFFFFFFULL; } + /* Grab the interface MTU, if we got it */ + tmp = net_dhcp_get_16bit(pkt, DHCP_OPTION_INTERFACE_MTU, len); + + if(tmp != 0) { + net_default_dev->mtu = (int)((uint16)tmp); + } + state = DHCP_STATE_BOUND; irq_restore(old); @@ -455,7 +475,7 @@ struct dhcp_pkt_out *qpkt; uint64 now; struct sockaddr_in addr; - uint8 buf[1024]; + uint8 buf[1500]; ssize_t len = 0; socklen_t addr_len = sizeof(struct sockaddr_in); dhcp_pkt_t *pkt = (dhcp_pkt_t *)buf, *pkt2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-06-05 02:53:14
|
Revision: 640 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=640&view=rev Author: ljsebald Date: 2009-06-05 02:02:22 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Adding in simple statistics system for IPv4 and UDP (and fixing comment at the top of the second modifier volume example). Modified Paths: -------------- kos/doc/CHANGELOG kos/examples/dreamcast/network/basic/basic.c kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c kos/include/kos/net.h kos/kernel/net/net_ipv4.c kos/kernel/net/net_udp.c Modified: kos/doc/CHANGELOG =================================================================== --- kos/doc/CHANGELOG 2009-06-05 00:32:53 UTC (rev 639) +++ kos/doc/CHANGELOG 2009-06-05 02:02:22 UTC (rev 640) @@ -185,6 +185,9 @@ correct polygon header to be sent for sprites [LS] - DC Added in some support functions for PVR modifier volumes (and an example program that uses them) [LS] +- DC Added a modifier volume example using textures [LS] +- DC Added a simple statistics system to the IPv4 and UDP layers of the + network stack [LS] KallistiOS version 1.2.0 ----------------------------------------------- - DC Fix to use DCARM7_CFLAGS when compiling ARM driver [Christian Groessler == CG] Modified: kos/examples/dreamcast/network/basic/basic.c =================================================================== --- kos/examples/dreamcast/network/basic/basic.c 2009-06-05 00:32:53 UTC (rev 639) +++ kos/examples/dreamcast/network/basic/basic.c 2009-06-05 02:02:22 UTC (rev 640) @@ -1,7 +1,8 @@ /* KallistiOS ##version## - network.c - (c)2002 Dan Potter + basic.c + Copyright (C) 2002 Dan Potter + Copyright (C) 2009 Lawrence Sebald */ #include <kos.h> @@ -13,15 +14,45 @@ ping it, etc. Note that this program is totally portable as long as your KOS platform has networking capabilities, but I'm leaving it in "dreamcast" for now. - + +Now with statistics printing! + */ KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET); int main(int argc, char **argv) { + net_ipv4_stats_t ip; + net_udp_stats_t udp; + /* Wait for a bit so the user can ping, etc */ - usleep(10 * 1000 * 1000); + thd_sleep(10 * 1000); + /* Print out some statistics about the connection. */ + ip = net_ipv4_get_stats(); + udp = net_udp_get_stats(); + + printf("IPv4 Stats:\n" + "Packets sent successfully: %6d\n" + "Packets that failed to send: %6d\n" + "Packets received successfully: %6d\n" + "Packets rejected (bad size): %6d\n" + " (bad checksum): %6d\n" + " (bad protocol): %6d\n\n", + ip.pkt_sent, ip.pkt_send_failed, ip.pkt_recv, ip.pkt_recv_bad_size, + ip.pkt_recv_bad_chksum, ip.pkt_recv_bad_proto); + + printf("UDP Stats:\n" + "Packets sent successfully: %6d\n" + "Packets that failed to send: %6d\n" + "Packets received successfully: %6d\n" + "Packets rejected (bad size): %6d\n" + " (bad checksum): %6d\n" + " (no socket): %6d\n\n", + udp.pkt_sent, udp.pkt_send_failed, udp.pkt_recv, + udp.pkt_recv_bad_size, udp.pkt_recv_bad_chksum, + udp.pkt_recv_no_sock); + return 0; } Modified: kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c 2009-06-05 00:32:53 UTC (rev 639) +++ kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c 2009-06-05 02:02:22 UTC (rev 640) @@ -1,6 +1,6 @@ /* KallistiOS ##version## - examples/dreamcast/pvr/modifier_volume/modifier.c + examples/dreamcast/pvr/modifier_volume_tex/modifier.c Copyright (C) 2009 Lawrence Sebald This example shows off how to do a basic modifier volume (with textures). Modified: kos/include/kos/net.h =================================================================== --- kos/include/kos/net.h 2009-06-05 00:32:53 UTC (rev 639) +++ kos/include/kos/net.h 2009-06-05 02:02:22 UTC (rev 640) @@ -1,7 +1,8 @@ /* KallistiOS ##version## include/kos/net.h - (c)2002 Dan Potter + Copyright (C) 2002 Dan Potter + Copyright (C) 2005, 2006, 2007, 2008, 2009 Lawrence Sebald */ @@ -195,6 +196,20 @@ /***** net_ipv4.c *********************************************************/ +/* IPv4 statistics structure. This structure holds some basic statistics about + the IPv4 layer of the stack, and can be retrieved with the function below. */ +typedef struct net_ipv4_stats { + uint32 pkt_sent; /* Packets sent out successfully */ + uint32 pkt_send_failed; /* Packets that failed to send */ + uint32 pkt_recv; /* Packets received successfully */ + uint32 pkt_recv_bad_size; /* Packets of a bad size */ + uint32 pkt_recv_bad_chksum; /* Packets with a bad checksum */ + uint32 pkt_recv_bad_proto; /* Packets with an unknown protocol */ +} net_ipv4_stats_t; + +/* Retrieve statistics from the IPv4 layer. */ +net_ipv4_stats_t net_ipv4_get_stats(); + /* Create a 32-bit IP address, based on the individual numbers contained within the ip. */ uint32 net_ipv4_address(const uint8 addr[4]); @@ -205,6 +220,20 @@ /***** net_udp.c **********************************************************/ +/* UDP statistics structure. This structure holds some basic statistics about + the UDP layer of the stack, and can be retrieved with the function below. */ +typedef struct net_udp_stats { + uint32 pkt_sent; /* Packets sent out successfully */ + uint32 pkt_send_failed; /* Packets that failed to send */ + uint32 pkt_recv; /* Packets received successfully */ + uint32 pkt_recv_bad_size; /* Packets of a bad size */ + uint32 pkt_recv_bad_chksum; /* Packets with a bad checksum */ + uint32 pkt_recv_no_sock; /* Packets with to an unopened socket */ +} net_udp_stats_t; + +/* Retrieve statistics from the UDP layer. */ +net_udp_stats_t net_udp_get_stats(); + /* Init */ int net_udp_init(); Modified: kos/kernel/net/net_ipv4.c =================================================================== --- kos/kernel/net/net_ipv4.c 2009-06-05 00:32:53 UTC (rev 639) +++ kos/kernel/net/net_ipv4.c 2009-06-05 02:02:22 UTC (rev 640) @@ -2,7 +2,7 @@ kernel/net/net_ipv4.c - Copyright (C) 2005, 2006, 2007, 2008 Lawrence Sebald + Copyright (C) 2005, 2006, 2007, 2008, 2009 Lawrence Sebald Portions adapted from KOS' old net_icmp.c file: Copyright (c) 2002 Dan Potter @@ -18,6 +18,8 @@ #include "net_icmp.h" #include "net_udp.h" +static net_ipv4_stats_t ipv4_stats = { 0 }; + /* Perform an IP-style checksum on a block of data */ uint16 net_ipv4_checksum(const uint8 *data, int bytes) { uint32 sum = 0; @@ -105,6 +107,8 @@ /* Put the IP header / data into our packet */ memcpy(pkt, hdr, 4 * (hdr->version_ihl & 0x0f)); memcpy(pkt + 4 * (hdr->version_ihl & 0x0f), data, size); + + ++ipv4_stats.pkt_sent; /* Send it "away" */ net_ipv4_input(NULL, pkt, 4 * (hdr->version_ihl & 0x0f) + size); @@ -129,9 +133,11 @@ err = net_arp_lookup(net, dest_ip, dest_mac); if(err == -1) { errno = ENETUNREACH; + ++ipv4_stats.pkt_send_failed; return -1; } else if(err == -2) { + ++ipv4_stats.pkt_send_failed; return -2; } } @@ -148,6 +154,8 @@ memcpy(pkt + sizeof(eth_hdr_t) + 4 * (hdr->version_ihl & 0x0f), data, size); + ++ipv4_stats.pkt_sent; + /* Send it away */ net->if_tx(net, pkt, sizeof(ip_hdr_t) + size + sizeof(eth_hdr_t), NETIF_BLOCK); @@ -182,16 +190,20 @@ uint8 *data; int hdrlen; - if(pktsize < sizeof(ip_hdr_t)) + if(pktsize < sizeof(ip_hdr_t)) { /* This is obviously a bad packet, drop it */ + ++ipv4_stats.pkt_recv_bad_size; return -1; + } ip = (ip_hdr_t*) pkt; hdrlen = (ip->version_ihl & 0x0F) << 2; - if(pktsize < hdrlen) + if(pktsize < hdrlen) { /* The packet is smaller than the listed header length, bail */ + ++ipv4_stats.pkt_recv_bad_size; return -1; + } data = (uint8 *) (pkt + hdrlen); @@ -202,18 +214,22 @@ if(i != ip->checksum) { /* The checksums don't match, bail */ + ++ipv4_stats.pkt_recv_bad_chksum; return -1; } switch(ip->protocol) { case IPPROTO_ICMP: + ++ipv4_stats.pkt_recv; return net_icmp_input(src, ip, data, ntohs(ip->length) - hdrlen); case IPPROTO_UDP: + ++ipv4_stats.pkt_recv; return net_udp_input(src, ip, data, ntohs(ip->length) - hdrlen); } /* There's no handler for this packet type, bail out */ + ++ipv4_stats.pkt_recv_bad_proto; return -1; } @@ -227,3 +243,7 @@ out[2] = (uint8) ((addr >> 8) & 0xFF); out[3] = (uint8) (addr & 0xFF); } + +net_ipv4_stats_t net_ipv4_get_stats() { + return ipv4_stats; +} Modified: kos/kernel/net/net_udp.c =================================================================== --- kos/kernel/net/net_udp.c 2009-06-05 00:32:53 UTC (rev 639) +++ kos/kernel/net/net_udp.c 2009-06-05 02:02:22 UTC (rev 640) @@ -1,7 +1,7 @@ /* KallistiOS ##version## kernel/net/net_udp.c - Copyright (C) 2005, 2006, 2007, 2008 Lawrence Sebald + Copyright (C) 2005, 2006, 2007, 2008, 2009 Lawrence Sebald */ @@ -44,6 +44,7 @@ static struct udp_sock_list net_udp_sockets = LIST_HEAD_INITIALIZER(0); static mutex_t *udp_mutex = NULL; +static net_udp_stats_t udp_stats = { 0 }; int net_udp_accept(net_socket_t *hnd, struct sockaddr *addr, socklen_t *addr_len) { @@ -616,6 +617,7 @@ if(size <= sizeof(udp_hdr_t)) { /* Discard the packet, since it is too short to be of any interest. */ + ++udp_stats.pkt_recv_bad_size; return -1; } @@ -632,6 +634,7 @@ if(checksum != ps->checksum) { /* The checksums don't match, bail out */ + ++udp_stats.pkt_recv_bad_chksum; return -1; } @@ -665,12 +668,16 @@ mutex_unlock(udp_mutex); + ++udp_stats.pkt_recv; + return 0; } } mutex_unlock(udp_mutex); + ++udp_stats.pkt_recv_no_sock; + return -1; } @@ -683,6 +690,7 @@ if(net == NULL && net_default_dev == NULL) { errno = ENETDOWN; + ++udp_stats.pkt_send_failed; return -1; } @@ -725,16 +733,23 @@ } else if(err == -2) { errno = ENETUNREACH; + ++udp_stats.pkt_send_failed; return -1; } else if(err < 0) { + ++udp_stats.pkt_send_failed; return -1; } else { + ++udp_stats.pkt_sent; return size - sizeof(udp_hdr_t); } } +net_udp_stats_t net_udp_get_stats() { + return udp_stats; +} + int net_udp_init() { udp_mutex = mutex_create(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-06-05 01:12:59
|
Revision: 639 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=639&view=rev Author: ljsebald Date: 2009-06-05 00:32:53 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Better support for modifier volumes (really for the polygons affected by them), and an example of how to use modifiers with textures. Modified Paths: -------------- kos/examples/dreamcast/pvr/Makefile kos/examples/dreamcast/pvr/modifier_volume/modifier.c kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c kos/kernel/arch/dreamcast/include/dc/pvr.h Added Paths: ----------- kos/examples/dreamcast/pvr/modifier_volume_tex/ kos/examples/dreamcast/pvr/modifier_volume_tex/Makefile kos/examples/dreamcast/pvr/modifier_volume_tex/fruit.jpg kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c kos/examples/dreamcast/pvr/modifier_volume_tex/romdisk/ kos/examples/dreamcast/pvr/modifier_volume_tex/romdisk/crate.pcx Modified: kos/examples/dreamcast/pvr/Makefile =================================================================== --- kos/examples/dreamcast/pvr/Makefile 2009-06-03 19:53:33 UTC (rev 638) +++ kos/examples/dreamcast/pvr/Makefile 2009-06-05 00:32:53 UTC (rev 639) @@ -11,6 +11,7 @@ $(KOS_MAKE) -C pvrmark_strips_direct $(KOS_MAKE) -C texture_render $(KOS_MAKE) -C modifier_volume + $(KOS_MAKE) -C modifier_volume_tex clean: $(KOS_MAKE) -C plasma clean @@ -19,6 +20,7 @@ $(KOS_MAKE) -C pvrmark_strips_direct clean $(KOS_MAKE) -C texture_render clean $(KOS_MAKE) -C modifier_volume clean + $(KOS_MAKE) -C modifier_volume_tex clean dist: $(KOS_MAKE) -C plasma dist @@ -27,5 +29,6 @@ $(KOS_MAKE) -C pvrmark_strips_direct dist $(KOS_MAKE) -C texture_render dist $(KOS_MAKE) -C modifier_volume dist + $(KOS_MAKE) -C modifier_volume_tex dist Modified: kos/examples/dreamcast/pvr/modifier_volume/modifier.c =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume/modifier.c 2009-06-03 19:53:33 UTC (rev 638) +++ kos/examples/dreamcast/pvr/modifier_volume/modifier.c 2009-06-05 00:32:53 UTC (rev 639) @@ -18,7 +18,7 @@ static pvr_vertex_pcm_t verts[NUM_POLYS * 4]; -static pvr_poly_hdr_t phdr; +static pvr_poly_mod_hdr_t phdr; static pvr_mod_hdr_t mhdr, mhdr2; static float mx = 320.0f, my = 240.0f; static pvr_list_t list = PVR_LIST_OP_POLY; @@ -29,10 +29,8 @@ float x, y, z; uint32 argb = list == PVR_LIST_OP_POLY ? 0xFF0000FF : 0x80FF00FF; - pvr_poly_cxt_col(&cxt, list); - cxt.fmt.modifier = PVR_MODIFIER_ENABLE; - cxt.gen.modifier_mode = PVR_MODIFIER_NORMAL; - pvr_poly_compile(&phdr, &cxt); + pvr_poly_cxt_col_mod(&cxt, list); + pvr_poly_mod_compile(&phdr, &cxt); pvr_mod_compile(&mhdr, list + 1, PVR_MODIFIER_OTHER_POLY, PVR_CULLING_NONE); pvr_mod_compile(&mhdr2, list + 1, PVR_MODIFIER_INCLUDE_LAST_POLY, Added: kos/examples/dreamcast/pvr/modifier_volume_tex/Makefile =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume_tex/Makefile (rev 0) +++ kos/examples/dreamcast/pvr/modifier_volume_tex/Makefile 2009-06-05 00:32:53 UTC (rev 639) @@ -0,0 +1,42 @@ +# +# Basic KallistiOS skeleton / test program +# (c)2001 Dan Potter +# + +# Put the filename of the output binary here +TARGET = modifier.elf + +# List all of your C files here, but change the extension to ".o" +OBJS = modifier.o romdisk.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: + -rm -f $(TARGET) $(OBJS) romdisk.* romdisk/fruit.kmg + +rm-elf: + -rm -f $(TARGET) + +$(TARGET): $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \ + $(OBJS) $(OBJEXTRA) -lkmg -lpcx -lkosutils $(KOS_LIBS) + +romdisk.img: romdisk/fruit.kmg romdisk/crate.pcx + $(KOS_GENROMFS) -f romdisk.img -d romdisk -v + +romdisk.o: romdisk.img + $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o + +romdisk/fruit.kmg: fruit.jpg + $(KOS_BASE)/utils/vqenc/vqenc -t -v -q -k fruit.jpg + mv fruit.kmg romdisk/ + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) -n + +dist: + rm -f $(OBJS) romdisk.* romdisk/fruit.kmg + $(KOS_STRIP) $(TARGET) + Added: kos/examples/dreamcast/pvr/modifier_volume_tex/fruit.jpg =================================================================== (Binary files differ) Property changes on: kos/examples/dreamcast/pvr/modifier_volume_tex/fruit.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c (rev 0) +++ kos/examples/dreamcast/pvr/modifier_volume_tex/modifier.c 2009-06-05 00:32:53 UTC (rev 639) @@ -0,0 +1,252 @@ +/* KallistiOS ##version## + + examples/dreamcast/pvr/modifier_volume/modifier.c + Copyright (C) 2009 Lawrence Sebald + + This example shows off how to do a basic modifier volume (with textures). +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#include <dc/pvr.h> +#include <dc/maple.h> +#include <dc/maple/controller.h> + +#include <pcx/pcx.h> +#include <kmg/kmg.h> + +#define NUM_POLYS 10 + +static pvr_vertex_tpcm_t verts[NUM_POLYS * 4]; + +static pvr_poly_mod_hdr_t phdr; +static pvr_mod_hdr_t mhdr, mhdr2; +static float mx = 320.0f, my = 240.0f; +static pvr_list_t list = PVR_LIST_OP_POLY; +static pvr_ptr_t txr1, txr2; + +void setup() { + pvr_poly_cxt_t cxt; + int i; + float x, y, z; + int w1, h1, w2, h2; + uint32 fmt1, fmt2; + kos_img_t img; + + if(pcx_to_img("/rd/crate.pcx", &img)) { + printf("Failed to load /rd/crate.pcx\n"); + exit(1); + } + + w1 = img.w; + h1 = img.h; + fmt1 = PVR_TXRFMT_RGB565 | PVR_TXRFMT_TWIDDLED; + txr1 = pvr_mem_malloc(img.byte_count); + pvr_txr_load_kimg(&img, txr1, 0); + kos_img_free(&img, 0); + + if(kmg_to_img("/rd/fruit.kmg", &img)) { + printf("Failed to load /rd/fruit.kmg\n"); + exit(1); + } + + w2 = img.w; + h2 = img.h; + fmt2 = PVR_TXRFMT_RGB565 | PVR_TXRFMT_VQ_ENABLE | PVR_TXRFMT_TWIDDLED; + txr2 = pvr_mem_malloc(img.byte_count); + pvr_txr_load_kimg(&img, txr2, 0); + kos_img_free(&img, 0); + + printf("Loaded textures\n"); + + pvr_poly_cxt_txr_mod(&cxt, list, fmt1, w1, h1, txr1, PVR_FILTER_BILINEAR, + fmt2, w2, h2, txr2, PVR_FILTER_NONE); + pvr_poly_mod_compile(&phdr, &cxt); + + pvr_mod_compile(&mhdr, list + 1, PVR_MODIFIER_OTHER_POLY, PVR_CULLING_NONE); + pvr_mod_compile(&mhdr2, list + 1, PVR_MODIFIER_INCLUDE_LAST_POLY, + PVR_CULLING_NONE); + + for(i = 0; i < NUM_POLYS; ++i) { + x = rand() % 640; + y = rand() % 480; + z = rand() % 100 + 1; + + verts[i * 4].flags = PVR_CMD_VERTEX; + verts[i * 4].x = x - 50; + verts[i * 4].y = y + 50; + verts[i * 4].z = z; + verts[i * 4].u0 = 0.0f; + verts[i * 4].v0 = 1.0f; + verts[i * 4].argb0 = 0xFFFFFFFF; + verts[i * 4].oargb0 = 0xFF000000; + verts[i * 4].u1 = 0.0f; + verts[i * 4].v1 = 1.0f; + verts[i * 4].argb1 = 0xFFFFFFFF; + verts[i * 4].oargb1 = 0xFF000000; + verts[i * 4].d1 = verts[i * 4].d2 = verts[i * 4].d3 = + verts[i * 4].d4 = 0; + + verts[i * 4 + 1].flags = PVR_CMD_VERTEX; + verts[i * 4 + 1].x = x - 50; + verts[i * 4 + 1].y = y - 50; + verts[i * 4 + 1].z = z; + verts[i * 4 + 1].u0 = 0.0f; + verts[i * 4 + 1].v0 = 0.0f; + verts[i * 4 + 1].argb0 = 0xFFFFFFFF; + verts[i * 4 + 1].oargb0 = 0xFF000000; + verts[i * 4 + 1].u1 = 0.0f; + verts[i * 4 + 1].v1 = 0.0f; + verts[i * 4 + 1].argb1 = 0xFFFFFFFF; + verts[i * 4 + 1].oargb1 = 0xFF000000; + verts[i * 4 + 1].d1 = verts[i * 4 + 1].d2 = verts[i * 4 + 1].d3 = + verts[i * 4 + 1].d4 = 0; + + verts[i * 4 + 2].flags = PVR_CMD_VERTEX; + verts[i * 4 + 2].x = x + 50; + verts[i * 4 + 2].y = y + 50; + verts[i * 4 + 2].z = z; + verts[i * 4 + 2].u0 = 1.0f; + verts[i * 4 + 2].v0 = 1.0f; + verts[i * 4 + 2].argb0 = 0xFFFFFFFF; + verts[i * 4 + 2].oargb0 = 0xFF000000; + verts[i * 4 + 2].u1 = 1.0f; + verts[i * 4 + 2].v1 = 1.0f; + verts[i * 4 + 2].argb1 = 0xFFFFFFFF; + verts[i * 4 + 2].oargb1 = 0xFF000000; + verts[i * 4 + 2].d1 = verts[i * 4 + 2].d2 = verts[i * 4 + 2].d3 = + verts[i * 4 + 2].d4 = 0; + + verts[i * 4 + 3].flags = PVR_CMD_VERTEX_EOL; + verts[i * 4 + 3].x = x + 50; + verts[i * 4 + 3].y = y - 50; + verts[i * 4 + 3].z = z; + verts[i * 4 + 3].u0 = 1.0f; + verts[i * 4 + 3].v0 = 0.0f; + verts[i * 4 + 3].argb0 = 0xFFFFFFFF; + verts[i * 4 + 3].oargb0 = 0xFF000000; + verts[i * 4 + 3].u1 = 1.0f; + verts[i * 4 + 3].v1 = 0.0f; + verts[i * 4 + 3].argb1 = 0xFFFFFFFF; + verts[i * 4 + 3].oargb1 = 0xFF000000; + verts[i * 4 + 3].d1 = verts[i * 4 + 3].d2 = verts[i * 4 + 3].d3 = + verts[i * 4 + 3].d4 = 0; + } +} + +int check_start() { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) + return 0; + + if(state->buttons & CONT_START) + return 1; + + if(state->buttons & CONT_DPAD_UP) + my -= 1.0f; + if(state->buttons & CONT_DPAD_DOWN) + my += 1.0f; + if(state->buttons & CONT_DPAD_LEFT) + mx -= 1.0f; + if(state->buttons & CONT_DPAD_RIGHT) + mx += 1.0f; + } + + return 0; +} + +void do_frame() { + pvr_modifier_vol_t mod; + int i; + + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(list); + + pvr_prim(&phdr, sizeof(phdr)); + + for(i = 0; i < NUM_POLYS; ++i) { + pvr_prim(&verts[i * 4], sizeof(verts[i * 4])); + pvr_prim(&verts[i * 4 + 1], sizeof(verts[i * 4 + 1])); + pvr_prim(&verts[i * 4 + 2], sizeof(verts[i * 4 + 2])); + pvr_prim(&verts[i * 4 + 3], sizeof(verts[i * 4 + 3])); + } + + pvr_list_finish(); + + pvr_list_begin(list + 1); + + pvr_prim(&mhdr, sizeof(mhdr)); + + mod.flags = PVR_CMD_VERTEX_EOL; + mod.ax = mx; + mod.ay = my + 50.0f; + mod.az = 150.0f; + mod.bx = mx; + mod.by = my; + mod.bz = 150.0f; + mod.cx = mx + 50.0f; + mod.cy = my + 50.0f; + mod.cz = 150.0f; + mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0; + pvr_prim(&mod, sizeof(mod)); + + pvr_prim(&mhdr2, sizeof(mhdr2)); + + mod.flags = PVR_CMD_VERTEX_EOL; + mod.ax = mx; + mod.ay = my; + mod.az = 150.0f; + mod.bx = mx + 50.0f; + mod.by = my + 50.0f; + mod.bz = 150.0f; + mod.cx = mx + 50.0f; + mod.cy = my; + mod.cz = 150.0f; + mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0; + pvr_prim(&mod, sizeof(mod)); + + pvr_list_finish(); + pvr_scene_finish(); +} + +static pvr_init_params_t pvr_params = { + /* Enable Opaque and Opaque modifiers. */ + { PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, + PVR_BINSIZE_0 }, + 512 * 1024 +}; + +extern uint8 romdisk[]; +KOS_INIT_ROMDISK(romdisk); + +int main(int argc, char *argv[]) { + printf("---KallistiOS PVR Modifier Example (with textures)---\n"); + printf("Use the DPAD to move the modifier square around (it starts at "); + printf("(320, 240))\n"); + printf("Press Start to exit.\n"); + + srand(time(NULL)); + + pvr_init(&pvr_params); + + setup(); + + /* Go as long as the user hasn't pressed start on controller 1. */ + while(!check_start()) { + do_frame(); + } + + pvr_mem_free(txr1); + pvr_mem_free(txr2); + + return 0; +} Added: kos/examples/dreamcast/pvr/modifier_volume_tex/romdisk/crate.pcx =================================================================== (Binary files differ) Property changes on: kos/examples/dreamcast/pvr/modifier_volume_tex/romdisk/crate.pcx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-06-03 19:53:33 UTC (rev 638) +++ kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-06-05 00:32:53 UTC (rev 639) @@ -359,3 +359,266 @@ dst->d1 = dst->d2 = dst->d3 = dst->d4 = dst->d5 = dst->d6 = 0; } + +/* Compile a polygon context into a polygon header that is affected by + modifier volumes */ +void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src) { + int u, v; + uint32 txr_base; + + /* Basically we just take each parameter, clip it, shift it + into place, and OR it into the final result. */ + + /* The base values for CMD */ + dst->cmd = PVR_CMD_POLYHDR; + if (src->txr.enable == PVR_TEXTURE_ENABLE) + dst->cmd |= 8; + + /* Or in the list type, shading type, color and UV formats */ + dst->cmd |= (src->list_type << PVR_TA_CMD_TYPE_SHIFT) & PVR_TA_CMD_TYPE_MASK; + dst->cmd |= (src->fmt.color << PVR_TA_CMD_CLRFMT_SHIFT) & PVR_TA_CMD_CLRFMT_MASK; + dst->cmd |= (src->gen.shading << PVR_TA_CMD_SHADE_SHIFT) & PVR_TA_CMD_SHADE_MASK; + dst->cmd |= (src->fmt.uv << PVR_TA_CMD_UVFMT_SHIFT) & PVR_TA_CMD_UVFMT_MASK; + dst->cmd |= (src->gen.clip_mode << PVR_TA_CMD_USERCLIP_SHIFT) & PVR_TA_CMD_USERCLIP_MASK; + dst->cmd |= (src->fmt.modifier << PVR_TA_CMD_MODIFIER_SHIFT) & PVR_TA_CMD_MODIFIER_MASK; + dst->cmd |= (src->gen.modifier_mode << PVR_TA_CMD_MODIFIERMODE_SHIFT) & PVR_TA_CMD_MODIFIERMODE_MASK; + + /* Polygon mode 1 */ + dst->mode1 = (src->depth.comparison << PVR_TA_PM1_DEPTHCMP_SHIFT) & PVR_TA_PM1_DEPTHCMP_MASK; + dst->mode1 |= (src->gen.culling << PVR_TA_PM1_CULLING_SHIFT) & PVR_TA_PM1_CULLING_MASK; + dst->mode1 |= (src->depth.write << PVR_TA_PM1_DEPTHWRITE_SHIFT) & PVR_TA_PM1_DEPTHWRITE_MASK; + dst->mode1 |= (src->txr.enable << PVR_TA_PM1_TXRENABLE_SHIFT) & PVR_TA_PM1_TXRENABLE_MASK; + + /* Polygon mode 2 (outside volume) */ + dst->mode2_0 = (src->blend.src << PVR_TA_PM2_SRCBLEND_SHIFT) & PVR_TA_PM2_SRCBLEND_MASK; + dst->mode2_0 |= (src->blend.dst << PVR_TA_PM2_DSTBLEND_SHIFT) & PVR_TA_PM2_DSTBLEND_MASK; + dst->mode2_0 |= (src->blend.src_enable << PVR_TA_PM2_SRCENABLE_SHIFT) & PVR_TA_PM2_SRCENABLE_MASK; + dst->mode2_0 |= (src->blend.dst_enable << PVR_TA_PM2_DSTENABLE_SHIFT) & PVR_TA_PM2_DSTENABLE_MASK; + dst->mode2_0 |= (src->gen.fog_type << PVR_TA_PM2_FOG_SHIFT) & PVR_TA_PM2_FOG_MASK; + dst->mode2_0 |= (src->gen.color_clamp << PVR_TA_PM2_CLAMP_SHIFT) & PVR_TA_PM2_CLAMP_MASK; + dst->mode2_0 |= (src->gen.alpha << PVR_TA_PM2_ALPHA_SHIFT) & PVR_TA_PM2_ALPHA_MASK; + + if (src->txr.enable == PVR_TEXTURE_DISABLE) { + dst->mode3_0 = 0; + } else { + dst->mode2_0 |= (src->txr.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; + dst->mode2_0 |= (src->txr.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; + dst->mode2_0 |= (src->txr.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; + dst->mode2_0 |= (src->txr.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; + dst->mode2_0 |= (src->txr.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; + dst->mode2_0 |= (src->txr.env << PVR_TA_PM2_TXRENV_SHIFT) & PVR_TA_PM2_TXRENV_MASK; + + switch (src->txr.width) { + case 8: u = 0; break; + case 16: u = 1; break; + case 32: u = 2; break; + case 64: u = 3; break; + case 128: u = 4; break; + case 256: u = 5; break; + case 512: u = 6; break; + case 1024: u = 7; break; + default: assert_msg(0, "Invalid texture U size"); u = 0; break; + } + + switch (src->txr.height) { + case 8: v = 0; break; + case 16: v = 1; break; + case 32: v = 2; break; + case 64: v = 3; break; + case 128: v = 4; break; + case 256: v = 5; break; + case 512: v = 6; break; + case 1024: v = 7; break; + default: assert_msg(0, "Invalid texture V size"); v = 0; break; + } + + dst->mode2_0 |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; + dst->mode2_0 |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; + + /* Polygon mode 3 (outside volume) */ + dst->mode3_0 = (src->txr.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; + dst->mode3_0 |= (src->txr.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; + + /* Convert the texture address */ + txr_base = (uint32)src->txr.base; + txr_base = (txr_base & 0x00fffff8) >> 3; + dst->mode3_0 |= txr_base; + } + + /* Polygon mode 2 (within volume) */ + dst->mode2_1 = (src->blend.src2 << PVR_TA_PM2_SRCBLEND_SHIFT) & PVR_TA_PM2_SRCBLEND_MASK; + dst->mode2_1 |= (src->blend.dst2 << PVR_TA_PM2_DSTBLEND_SHIFT) & PVR_TA_PM2_DSTBLEND_MASK; + dst->mode2_1 |= (src->blend.src_enable2 << PVR_TA_PM2_SRCENABLE_SHIFT) & PVR_TA_PM2_SRCENABLE_MASK; + dst->mode2_1 |= (src->blend.dst_enable2 << PVR_TA_PM2_DSTENABLE_SHIFT) & PVR_TA_PM2_DSTENABLE_MASK; + dst->mode2_1 |= (src->gen.fog_type2 << PVR_TA_PM2_FOG_SHIFT) & PVR_TA_PM2_FOG_MASK; + dst->mode2_1 |= (src->gen.color_clamp2 << PVR_TA_PM2_CLAMP_SHIFT) & PVR_TA_PM2_CLAMP_MASK; + dst->mode2_1 |= (src->gen.alpha2 << PVR_TA_PM2_ALPHA_SHIFT) & PVR_TA_PM2_ALPHA_MASK; + + if (src->txr2.enable == PVR_TEXTURE_DISABLE) { + dst->mode3_1 = 0; + } else { + dst->mode2_1 |= (src->txr2.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; + dst->mode2_1 |= (src->txr2.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; + dst->mode2_1 |= (src->txr2.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; + dst->mode2_1 |= (src->txr2.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; + dst->mode2_1 |= (src->txr2.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; + dst->mode2_1 |= (src->txr2.env << PVR_TA_PM2_TXRENV_SHIFT) & PVR_TA_PM2_TXRENV_MASK; + + switch (src->txr2.width) { + case 8: u = 0; break; + case 16: u = 1; break; + case 32: u = 2; break; + case 64: u = 3; break; + case 128: u = 4; break; + case 256: u = 5; break; + case 512: u = 6; break; + case 1024: u = 7; break; + default: assert_msg(0, "Invalid texture U size"); u = 0; break; + } + + switch (src->txr2.height) { + case 8: v = 0; break; + case 16: v = 1; break; + case 32: v = 2; break; + case 64: v = 3; break; + case 128: v = 4; break; + case 256: v = 5; break; + case 512: v = 6; break; + case 1024: v = 7; break; + default: assert_msg(0, "Invalid texture V size"); v = 0; break; + } + + dst->mode2_1 |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; + dst->mode2_1 |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; + + /* Polygon mode 3 (within volume) */ + dst->mode3_1 = (src->txr2.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; + dst->mode3_1 |= (src->txr2.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; + + /* Convert the texture address */ + txr_base = (uint32)src->txr2.base; + txr_base = (txr_base & 0x00fffff8) >> 3; + dst->mode3_1 |= txr_base; + } + + dst->d1 = dst->d2 = 0xffffffff; +} + +/* Create a colored polygon context for polygons affected by modifier volumes */ +void pvr_poly_cxt_col_mod(pvr_poly_cxt_t *dst, pvr_list_t list) { + int alpha; + + /* Start off blank */ + memset(dst, 0, sizeof(pvr_poly_cxt_t)); + + /* Fill in a few values */ + dst->list_type = list; + alpha = list > PVR_LIST_OP_MOD; + dst->fmt.color = PVR_CLRFMT_ARGBPACKED; + dst->fmt.uv = PVR_UVFMT_32BIT; + dst->gen.shading = PVR_SHADE_GOURAUD; + dst->depth.comparison = PVR_DEPTHCMP_GREATER; + dst->depth.write = PVR_DEPTHWRITE_ENABLE; + dst->gen.culling = PVR_CULLING_CCW; + dst->fmt.modifier = PVR_MODIFIER_ENABLE; + dst->gen.modifier_mode = PVR_MODIFIER_NORMAL; + dst->txr.enable = PVR_TEXTURE_DISABLE; + dst->txr2.enable = PVR_TEXTURE_DISABLE; + if (!alpha) { + dst->gen.alpha = PVR_ALPHA_DISABLE; + dst->blend.src = PVR_BLEND_ONE; + dst->blend.dst = PVR_BLEND_ZERO; + dst->gen.alpha2 = PVR_ALPHA_DISABLE; + dst->blend.src2 = PVR_BLEND_ONE; + dst->blend.dst2 = PVR_BLEND_ZERO; + } else { + dst->gen.alpha = PVR_ALPHA_ENABLE; + dst->blend.src = PVR_BLEND_SRCALPHA; + dst->blend.dst = PVR_BLEND_INVSRCALPHA; + dst->gen.alpha2 = PVR_ALPHA_ENABLE; + dst->blend.src2 = PVR_BLEND_SRCALPHA; + dst->blend.dst2 = PVR_BLEND_INVSRCALPHA; + } + dst->blend.src_enable = PVR_BLEND_DISABLE; + dst->blend.dst_enable = PVR_BLEND_DISABLE; + dst->gen.fog_type = PVR_FOG_DISABLE; + dst->gen.color_clamp = PVR_CLRCLAMP_DISABLE; + dst->blend.src_enable2 = PVR_BLEND_DISABLE; + dst->blend.dst_enable2 = PVR_BLEND_DISABLE; + dst->gen.fog_type2 = PVR_FOG_DISABLE; + dst->gen.color_clamp2 = PVR_CLRCLAMP_DISABLE; +} + +/* Create a textured polygon context for polygons affected by modifier + volumes */ +void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, + int textureformat, int tw, int th, + pvr_ptr_t textureaddr, int filtering, + int textureformat2, int tw2, int th2, + pvr_ptr_t textureaddr2, int filtering2) { + int alpha; + + /* Start off blank */ + memset(dst, 0, sizeof(pvr_poly_cxt_t)); + + /* Fill in a few values */ + dst->list_type = list; + alpha = list > PVR_LIST_OP_MOD; + dst->fmt.color = PVR_CLRFMT_ARGBPACKED; + dst->fmt.uv = PVR_UVFMT_32BIT; + dst->gen.shading = PVR_SHADE_GOURAUD; + dst->depth.comparison = PVR_DEPTHCMP_GREATER; + dst->depth.write = PVR_DEPTHWRITE_ENABLE; + dst->gen.culling = PVR_CULLING_CCW; + dst->fmt.modifier = PVR_MODIFIER_ENABLE; + dst->gen.modifier_mode = PVR_MODIFIER_NORMAL; + dst->txr.enable = PVR_TEXTURE_ENABLE; + dst->txr2.enable = PVR_TEXTURE_ENABLE; + if (!alpha) { + dst->gen.alpha = PVR_ALPHA_DISABLE; + dst->txr.alpha = PVR_TXRALPHA_ENABLE; + dst->blend.src = PVR_BLEND_ONE; + dst->blend.dst = PVR_BLEND_ZERO; + dst->txr.env = PVR_TXRENV_MODULATE; + dst->gen.alpha2 = PVR_ALPHA_DISABLE; + dst->txr2.alpha = PVR_TXRALPHA_ENABLE; + dst->blend.src2 = PVR_BLEND_ONE; + dst->blend.dst2 = PVR_BLEND_ZERO; + dst->txr2.env = PVR_TXRENV_MODULATE; + } else { + dst->gen.alpha = PVR_ALPHA_ENABLE; + dst->txr.alpha = PVR_TXRALPHA_ENABLE; + dst->blend.src = PVR_BLEND_SRCALPHA; + dst->blend.dst = PVR_BLEND_INVSRCALPHA; + dst->txr.env = PVR_TXRENV_MODULATEALPHA; + dst->gen.alpha2 = PVR_ALPHA_ENABLE; + dst->txr2.alpha = PVR_TXRALPHA_ENABLE; + dst->blend.src2 = PVR_BLEND_SRCALPHA; + dst->blend.dst2 = PVR_BLEND_INVSRCALPHA; + dst->txr2.env = PVR_TXRENV_MODULATEALPHA; + } + dst->blend.src_enable = PVR_BLEND_DISABLE; + dst->blend.dst_enable = PVR_BLEND_DISABLE; + dst->gen.fog_type = PVR_FOG_DISABLE; + dst->gen.color_clamp = PVR_CLRCLAMP_DISABLE; + dst->txr.uv_flip = PVR_UVFLIP_NONE; + dst->txr.uv_clamp = PVR_UVCLAMP_NONE; + dst->txr.filter = filtering; + dst->txr.mipmap_bias = PVR_MIPBIAS_NORMAL; + dst->txr.width = tw; + dst->txr.height = th; + dst->txr.base = textureaddr; + dst->txr.format = textureformat; + dst->blend.src_enable2 = PVR_BLEND_DISABLE; + dst->blend.dst_enable2 = PVR_BLEND_DISABLE; + dst->gen.fog_type2 = PVR_FOG_DISABLE; + dst->gen.color_clamp2 = PVR_CLRCLAMP_DISABLE; + dst->txr2.uv_flip = PVR_UVFLIP_NONE; + dst->txr2.uv_clamp = PVR_UVCLAMP_NONE; + dst->txr2.filter = filtering2; + dst->txr2.mipmap_bias = PVR_MIPBIAS_NORMAL; + dst->txr2.width = tw2; + dst->txr2.height = th2; + dst->txr2.base = textureaddr2; + dst->txr2.format = textureformat2; +} Modified: kos/kernel/arch/dreamcast/include/dc/pvr.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-06-03 19:53:33 UTC (rev 638) +++ kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-06-05 00:32:53 UTC (rev 639) @@ -48,10 +48,15 @@ int color_clamp; int clip_mode; int modifier_mode; + int alpha2; + int fog_type2; + int color_clamp2; } gen; struct { int src, dst; int src_enable, dst_enable; + int src2, dst2; + int src_enable2, dst_enable2; } blend; struct { int color; @@ -76,6 +81,20 @@ int format; /* bit format, vq, twiddle, stride */ pvr_ptr_t base; /* texture location */ } txr; + struct { + int enable; + int filter; /* none, bi-linear, tri-linear, etc */ + int mipmap; + int mipmap_bias; + int uv_flip; + int uv_clamp; + int alpha; + int env; + int width; + int height; + int format; /* bit format, vq, twiddle, stride */ + pvr_ptr_t base; /* texture location */ + } txr2; } pvr_poly_cxt_t; /* Sprite context; use this somewhat readable format to specify your @@ -279,8 +298,8 @@ typedef struct { uint32 cmd; /* TA command */ uint32 mode1; /* mode parameters */ + uint32 mode2_0, mode3_0; uint32 mode2_1, mode3_1; - uint32 mode2_2, mode3_2; uint32 d1, d2; /* dummies */ } pvr_poly_mod_hdr_t; @@ -932,6 +951,22 @@ void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, uint32 cull); +/* Compile a polygon context into a polygon header that is affected by + modifier volumes */ +void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src); + +/* Create a colored polygon context for polygons affected by + modifier volumes */ +void pvr_poly_cxt_col_mod(pvr_poly_cxt_t *dst, pvr_list_t list); + +/* Create a textured polygon context for polygons affected by + modifier volumes */ +void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, + int textureformat, int tw, int th, + pvr_ptr_t textureaddr, int filtering, + int textureformat2, int tw2, int th2, + pvr_ptr_t textureaddr2, int filtering2); + /* Texture handling **************************************************/ /* Helper functions for handling texture tasks of various kinds. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-06-03 19:53:40
|
Revision: 638 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=638&view=rev Author: ljsebald Date: 2009-06-03 19:53:33 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Adding in support functions for modifier volumes and a simple example. Modified Paths: -------------- kos/doc/CHANGELOG kos/examples/dreamcast/pvr/Makefile kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c kos/kernel/arch/dreamcast/include/dc/pvr.h Added Paths: ----------- kos/examples/dreamcast/pvr/modifier_volume/ kos/examples/dreamcast/pvr/modifier_volume/Makefile kos/examples/dreamcast/pvr/modifier_volume/modifier.c Modified: kos/doc/CHANGELOG =================================================================== --- kos/doc/CHANGELOG 2009-06-02 02:54:25 UTC (rev 637) +++ kos/doc/CHANGELOG 2009-06-03 19:53:33 UTC (rev 638) @@ -182,7 +182,9 @@ - *** Added kthread_once function (think pthread_once) [LS] - *** Added pthreads-like thread-local storage [LS] - DC Added in support for untextured PVR sprites and added support for the more - correct polygon header to be sent for sprites [LS] + correct polygon header to be sent for sprites [LS] +- DC Added in some support functions for PVR modifier volumes (and an example + program that uses them) [LS] KallistiOS version 1.2.0 ----------------------------------------------- - DC Fix to use DCARM7_CFLAGS when compiling ARM driver [Christian Groessler == CG] Modified: kos/examples/dreamcast/pvr/Makefile =================================================================== --- kos/examples/dreamcast/pvr/Makefile 2009-06-02 02:54:25 UTC (rev 637) +++ kos/examples/dreamcast/pvr/Makefile 2009-06-03 19:53:33 UTC (rev 638) @@ -10,6 +10,7 @@ $(KOS_MAKE) -C pvrmark_strips $(KOS_MAKE) -C pvrmark_strips_direct $(KOS_MAKE) -C texture_render + $(KOS_MAKE) -C modifier_volume clean: $(KOS_MAKE) -C plasma clean @@ -17,6 +18,7 @@ $(KOS_MAKE) -C pvrmark_strips clean $(KOS_MAKE) -C pvrmark_strips_direct clean $(KOS_MAKE) -C texture_render clean + $(KOS_MAKE) -C modifier_volume clean dist: $(KOS_MAKE) -C plasma dist @@ -24,5 +26,6 @@ $(KOS_MAKE) -C pvrmark_strips dist $(KOS_MAKE) -C pvrmark_strips_direct dist $(KOS_MAKE) -C texture_render dist + $(KOS_MAKE) -C modifier_volume dist Added: kos/examples/dreamcast/pvr/modifier_volume/Makefile =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume/Makefile (rev 0) +++ kos/examples/dreamcast/pvr/modifier_volume/Makefile 2009-06-03 19:53:33 UTC (rev 638) @@ -0,0 +1,32 @@ +# +# Basic KallistiOS skeleton / test program +# (c)2001 Dan Potter +# + +# Put the filename of the output binary here +TARGET = modifier.elf + +# List all of your C files here, but change the extension to ".o" +OBJS = modifier.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) $(KOS_LIBS) + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) -n + +dist: + rm -f $(OBJS) + $(KOS_STRIP) $(TARGET) + Added: kos/examples/dreamcast/pvr/modifier_volume/modifier.c =================================================================== --- kos/examples/dreamcast/pvr/modifier_volume/modifier.c (rev 0) +++ kos/examples/dreamcast/pvr/modifier_volume/modifier.c 2009-06-03 19:53:33 UTC (rev 638) @@ -0,0 +1,200 @@ +/* KallistiOS ##version## + + examples/dreamcast/pvr/modifier_volume/modifier.c + Copyright (C) 2009 Lawrence Sebald + + This example shows off how to do a basic modifier volume. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#include <dc/pvr.h> +#include <dc/maple.h> +#include <dc/maple/controller.h> + +#define NUM_POLYS 10 + +static pvr_vertex_pcm_t verts[NUM_POLYS * 4]; + +static pvr_poly_hdr_t phdr; +static pvr_mod_hdr_t mhdr, mhdr2; +static float mx = 320.0f, my = 240.0f; +static pvr_list_t list = PVR_LIST_OP_POLY; + +void setup() { + pvr_poly_cxt_t cxt; + int i; + float x, y, z; + uint32 argb = list == PVR_LIST_OP_POLY ? 0xFF0000FF : 0x80FF00FF; + + pvr_poly_cxt_col(&cxt, list); + cxt.fmt.modifier = PVR_MODIFIER_ENABLE; + cxt.gen.modifier_mode = PVR_MODIFIER_NORMAL; + pvr_poly_compile(&phdr, &cxt); + + pvr_mod_compile(&mhdr, list + 1, PVR_MODIFIER_OTHER_POLY, PVR_CULLING_NONE); + pvr_mod_compile(&mhdr2, list + 1, PVR_MODIFIER_INCLUDE_LAST_POLY, + PVR_CULLING_NONE); + + for(i = 0; i < NUM_POLYS; ++i) { + x = rand() % 640; + y = rand() % 480; + z = rand() % 100 + 1; + + verts[i * 4].flags = PVR_CMD_VERTEX; + verts[i * 4].x = x - 50; + verts[i * 4].y = y + 50; + verts[i * 4].z = z; + verts[i * 4].argb0 = argb; + verts[i * 4].argb1 = 0xFF00FF00; + verts[i * 4].d1 = verts[i * 4].d2 = 0; + + verts[i * 4 + 1].flags = PVR_CMD_VERTEX; + verts[i * 4 + 1].x = x - 50; + verts[i * 4 + 1].y = y - 50; + verts[i * 4 + 1].z = z; + verts[i * 4 + 1].argb0 = argb; + verts[i * 4 + 1].argb1 = 0xFF00FF00; + verts[i * 4 + 1].d1 = verts[i * 4 + 1].d2 = 0; + + verts[i * 4 + 2].flags = PVR_CMD_VERTEX; + verts[i * 4 + 2].x = x + 50; + verts[i * 4 + 2].y = y + 50; + verts[i * 4 + 2].z = z; + verts[i * 4 + 2].argb0 = argb; + verts[i * 4 + 2].argb1 = 0xFF00FF00; + verts[i * 4 + 2].d1 = verts[i * 4 + 2].d2 = 0; + + verts[i * 4 + 3].flags = PVR_CMD_VERTEX_EOL; + verts[i * 4 + 3].x = x + 50; + verts[i * 4 + 3].y = y - 50; + verts[i * 4 + 3].z = z; + verts[i * 4 + 3].argb0 = argb; + verts[i * 4 + 3].argb1 = 0xFF00FF00; + verts[i * 4 + 3].d1 = verts[i * 4 + 3].d2 = 0; + } +} + +int check_start() { + maple_device_t *cont; + cont_state_t *state; + static int taken = 0; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) + return 0; + + if(state->buttons & CONT_START) + return 1; + + if(state->buttons & CONT_DPAD_UP) + my -= 1.0f; + if(state->buttons & CONT_DPAD_DOWN) + my += 1.0f; + if(state->buttons & CONT_DPAD_LEFT) + mx -= 1.0f; + if(state->buttons & CONT_DPAD_RIGHT) + mx += 1.0f; + + if((state->buttons & CONT_A) && !taken) { + list = list == PVR_LIST_OP_POLY ? PVR_LIST_TR_POLY : + PVR_LIST_OP_POLY; + setup(); + taken = 1; + } + else if(!(state->buttons & CONT_A)) { + taken = 0; + } + } + + return 0; +} + +void do_frame() { + pvr_modifier_vol_t mod; + int i; + + pvr_wait_ready(); + pvr_scene_begin(); + pvr_list_begin(list); + + pvr_prim(&phdr, sizeof(phdr)); + + for(i = 0; i < NUM_POLYS; ++i) { + pvr_prim(&verts[i * 4], sizeof(verts[i * 4])); + pvr_prim(&verts[i * 4 + 1], sizeof(verts[i * 4 + 1])); + pvr_prim(&verts[i * 4 + 2], sizeof(verts[i * 4 + 2])); + pvr_prim(&verts[i * 4 + 3], sizeof(verts[i * 4 + 3])); + } + + pvr_list_finish(); + + pvr_list_begin(list + 1); + + pvr_prim(&mhdr, sizeof(mhdr)); + + mod.flags = PVR_CMD_VERTEX_EOL; + mod.ax = mx; + mod.ay = my + 50.0f; + mod.az = 150.0f; + mod.bx = mx; + mod.by = my; + mod.bz = 150.0f; + mod.cx = mx + 50.0f; + mod.cy = my + 50.0f; + mod.cz = 150.0f; + mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0; + pvr_prim(&mod, sizeof(mod)); + + pvr_prim(&mhdr2, sizeof(mhdr2)); + + mod.flags = PVR_CMD_VERTEX_EOL; + mod.ax = mx; + mod.ay = my; + mod.az = 150.0f; + mod.bx = mx + 50.0f; + mod.by = my + 50.0f; + mod.bz = 150.0f; + mod.cx = mx + 50.0f; + mod.cy = my; + mod.cz = 150.0f; + mod.d1 = mod.d2 = mod.d3 = mod.d4 = mod.d5 = mod.d6 = 0; + pvr_prim(&mod, sizeof(mod)); + + pvr_list_finish(); + pvr_scene_finish(); +} + +static pvr_init_params_t pvr_params = { + /* Enable Opaque, Opaque modifiers, Translucent, and Translucent + modifiers. */ + { PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_16, + PVR_BINSIZE_0 }, + 512 * 1024 +}; + +int main(int argc, char *argv[]) { + printf("---KallistiOS PVR Modifier Example---\n"); + printf("Press A to toggle between translucent and opaque polygons.\n"); + printf("Use the DPAD to move the modifier square around (it starts at "); + printf("(320, 240))\n"); + printf("Press Start to exit.\n"); + + srand(time(NULL)); + + pvr_init(&pvr_params); + + setup(); + + /* Go as long as the user hasn't pressed start on controller 1. */ + while(!check_start()) { + do_frame(); + } + + return 0; +} Modified: kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-06-02 02:54:25 UTC (rev 637) +++ kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-06-03 19:53:33 UTC (rev 638) @@ -103,8 +103,17 @@ dst->mode3 |= txr_base; } - /* Dummy values */ - dst->d1 = dst->d2 = dst->d3 = dst->d4 = 0xffffffff; + if(src->fmt.modifier) { + /* If we're affected by a modifier volume, silently promote the header + to the one that is affected by a modifier volume. */ + dst->d1 = dst->mode2; + dst->d2 = dst->mode3; + } + else { + dst->d1 = dst->d2 = 0xffffffff; + } + + dst->d3 = dst->d4 = 0xffffffff; } /* Create a colored polygon context with parameters similar to @@ -339,3 +348,14 @@ dst->argb = 0xFFFFFFFF; dst->oargb = 0x00000000; } + +void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, + uint32 cull) { + dst->cmd = PVR_CMD_MODIFIER; + dst->cmd |= (list << PVR_TA_CMD_TYPE_SHIFT) & PVR_TA_CMD_TYPE_MASK; + + dst->mode1 = (mode << PVR_TA_PM1_MODIFIERINST_SHIFT) & PVR_TA_PM1_MODIFIERINST_MASK; + dst->mode1 |= (cull << PVR_TA_PM1_CULLING_SHIFT) & PVR_TA_PM1_CULLING_MASK; + + dst->d1 = dst->d2 = dst->d3 = dst->d4 = dst->d5 = dst->d6 = 0; +} Modified: kos/kernel/arch/dreamcast/include/dc/pvr.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-06-02 02:54:25 UTC (rev 637) +++ kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-06-03 19:53:33 UTC (rev 638) @@ -252,8 +252,8 @@ #define PVR_MODIFIER_NORMAL 1 #define PVR_MODIFIER_OTHER_POLY 0 /* PM1 modifer instruction */ -#define PVR_MODIFIER_FIRST_POLY 1 /* ...in inclusion vol */ -#define PVR_MODIFIER_LAST_POLY 2 /* ...in exclusion vol */ +#define PVR_MODIFIER_INCLUDE_LAST_POLY 1 /* ...in inclusion vol */ +#define PVR_MODIFIER_EXCLUDE_LAST_POLY 2 /* ...in exclusion vol */ /* "Polygon header" -- this is the hardware equivalent of a rendering @@ -273,6 +273,17 @@ float a, r, g, b; /* color */ } pvr_poly_ic_hdr_t; +/* Polygon header to be used with modifier volumes. This is the + equivalent of a pvr_poly_hdr_t for use when a polygon is to + be used with modifier volumes. */ +typedef struct { + uint32 cmd; /* TA command */ + uint32 mode1; /* mode parameters */ + uint32 mode2_1, mode3_1; + uint32 mode2_2, mode3_2; + uint32 d1, d2; /* dummies */ +} pvr_poly_mod_hdr_t; + /* Polygon header specifically for sprites. */ typedef struct { uint32 cmd; /* TA command */ @@ -282,6 +293,13 @@ uint32 d1, d2; /* dummies */ } pvr_sprite_hdr_t; +/* Modifier volume header. */ +typedef struct { + uint32 cmd; /* TA command */ + uint32 mode1; /* mode parameter */ + uint32 d1, d2, d3, d4, d5, d6; /* dummies */ +} pvr_mod_hdr_t; + /* Generic vertex type; the PVR chip itself supports many more vertex types, but this is the main one that can be used with both textured and non-textured polygons, and is fairly fast. You can find other @@ -294,6 +312,17 @@ uint32 oargb; /* offset color */ } pvr_vertex_t; +/* Non-textured, packed color, affected by modifier volume. This + vertex type has two copies of colors. The second color is used when + enclosed within a modifier volume. */ +typedef struct { + uint32 flags; + float x, y, z; + uint32 argb0; + uint32 argb1; + uint32 d1, d2; +} pvr_vertex_pcm_t; + /* Textured, packed color, affected by modifer volume. Note that this vertex type has two copies of colors, offset colors and texture coords. The second set of texture coords, colors, and offset colors @@ -310,9 +339,9 @@ uint32 d1, d2, d3, d4; /* dummies */ } pvr_vertex_tpcm_t; -/* Textured sprite. This vertex type is to be used with the intensity - colored polygon header and the sprite related commands to draw - hardware accelerated, textured sprites. */ +/* Textured sprite. This vertex type is to be used with the sprite + polygon header and the sprite related commands to draw textured + sprites. */ typedef struct { uint32 flags; float ax, ay, az; @@ -367,7 +396,7 @@ #define PVR_CMD_VERTEX 0xe0000000 #define PVR_CMD_VERTEX_EOL 0xf0000000 #define PVR_CMD_USERCLIP 0x20000000 -#define PVR_CMD_MODIFIER 0x80040000 +#define PVR_CMD_MODIFIER 0x80000000 #define PVR_CMD_SPRITE 0xA0000000 /* Constants and bitmasks for handling polygon headers; note that thanks @@ -407,7 +436,7 @@ #define PVR_TA_PM1_TXRENABLE_MASK (1 << PVR_TA_PM1_TXRENABLE_SHIFT) #define PVR_TA_PM1_MODIFIERINST_SHIFT 29 -#define PVR_TA_PM1_MODIFIERINST_MASK (2 << PVR_TA_PM1_MODIFIERINST_SHIFT) +#define PVR_TA_PM1_MODIFIERINST_MASK (3 << PVR_TA_PM1_MODIFIERINST_SHIFT) #define PVR_TA_PM2_SRCBLEND_SHIFT 29 #define PVR_TA_PM2_SRCBLEND_MASK (7 << PVR_TA_PM2_SRCBLEND_SHIFT) @@ -899,6 +928,10 @@ int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering); +/* Create a modifier volume context */ +void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, + uint32 cull); + /* Texture handling **************************************************/ /* Helper functions for handling texture tasks of various kinds. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-06-02 02:54:26
|
Revision: 637 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=637&view=rev Author: ljsebald Date: 2009-06-02 02:54:25 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Adding support for untextured PVR sprites. Modified Paths: -------------- kos/doc/CHANGELOG kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c kos/kernel/arch/dreamcast/include/dc/pvr.h Modified: kos/doc/CHANGELOG =================================================================== --- kos/doc/CHANGELOG 2009-05-09 00:13:03 UTC (rev 636) +++ kos/doc/CHANGELOG 2009-06-02 02:54:25 UTC (rev 637) @@ -181,6 +181,8 @@ device. [LS] - *** Added kthread_once function (think pthread_once) [LS] - *** Added pthreads-like thread-local storage [LS] +- DC Added in support for untextured PVR sprites and added support for the more + correct polygon header to be sent for sprites [LS] KallistiOS version 1.2.0 ----------------------------------------------- - DC Fix to use DCARM7_CFLAGS when compiling ARM driver [Christian Groessler == CG] Modified: kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-05-09 00:13:03 UTC (rev 636) +++ kos/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c 2009-06-02 02:54:25 UTC (rev 637) @@ -187,8 +187,36 @@ dst->txr.format = textureformat; } -/* Create a textured sprite context with parameters similar to - the old "ta" function `ta_poly_hdr_txr' */ +/* Create an untextured sprite context. */ +void pvr_sprite_cxt_col(pvr_sprite_cxt_t *dst, pvr_list_t list) { + int alpha; + + /* Start off blank */ + memset(dst, 0, sizeof(pvr_poly_cxt_t)); + + /* Fill in a few values */ + dst->list_type = list; + alpha = list > PVR_LIST_OP_MOD; + dst->depth.comparison = PVR_DEPTHCMP_GREATER; + dst->depth.write = PVR_DEPTHWRITE_ENABLE; + dst->gen.culling = PVR_CULLING_CCW; + dst->txr.enable = PVR_TEXTURE_DISABLE; + if (!alpha) { + dst->gen.alpha = PVR_ALPHA_DISABLE; + dst->blend.src = PVR_BLEND_ONE; + dst->blend.dst = PVR_BLEND_ZERO; + } else { + dst->gen.alpha = PVR_ALPHA_ENABLE; + dst->blend.src = PVR_BLEND_SRCALPHA; + dst->blend.dst = PVR_BLEND_INVSRCALPHA; + } + dst->blend.src_enable = PVR_BLEND_DISABLE; + dst->blend.dst_enable = PVR_BLEND_DISABLE; + dst->gen.fog_type = PVR_FOG_DISABLE; + dst->gen.color_clamp = PVR_CLRCLAMP_DISABLE; +} + +/* Create a textured sprite context. */ void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering) { @@ -218,6 +246,7 @@ dst->blend.dst_enable = PVR_BLEND_DISABLE; dst->gen.fog_type = PVR_FOG_DISABLE; dst->gen.color_clamp = PVR_CLRCLAMP_DISABLE; + dst->txr.enable = PVR_TEXTURE_ENABLE; dst->txr.uv_flip = PVR_UVFLIP_NONE; dst->txr.uv_clamp = PVR_UVCLAMP_NONE; dst->txr.filter = filtering; @@ -228,8 +257,7 @@ dst->txr.format = textureformat; } -void pvr_sprite_compile(pvr_poly_ic_hdr_t *dst, - pvr_sprite_cxt_t *src) { +void pvr_sprite_compile(pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src) { int u, v; uint32 txr_base; @@ -237,8 +265,11 @@ into place, and OR it into the final result. */ /* The base values for CMD */ - dst->cmd = PVR_CMD_SPRITE | 8; + dst->cmd = PVR_CMD_SPRITE; + if (src->txr.enable == PVR_TEXTURE_ENABLE) + dst->cmd |= 8; + /* Or in the list type, clipping mode, and UV formats */ dst->cmd |= (src->list_type << PVR_TA_CMD_TYPE_SHIFT) & PVR_TA_CMD_TYPE_MASK; dst->cmd |= (PVR_UVFMT_16BIT << PVR_TA_CMD_UVFMT_SHIFT) & PVR_TA_CMD_UVFMT_MASK; @@ -248,7 +279,7 @@ dst->mode1 = (src->depth.comparison << PVR_TA_PM1_DEPTHCMP_SHIFT) & PVR_TA_PM1_DEPTHCMP_MASK; dst->mode1 |= (src->gen.culling << PVR_TA_PM1_CULLING_SHIFT) & PVR_TA_PM1_CULLING_MASK; dst->mode1 |= (src->depth.write << PVR_TA_PM1_DEPTHWRITE_SHIFT) & PVR_TA_PM1_DEPTHWRITE_MASK; - dst->mode1 |= (1 << PVR_TA_PM1_TXRENABLE_SHIFT) & PVR_TA_PM1_TXRENABLE_MASK; + dst->mode1 |= (src->txr.enable << PVR_TA_PM1_TXRENABLE_SHIFT) & PVR_TA_PM1_TXRENABLE_MASK; /* Polygon mode 2 */ dst->mode2 = (src->blend.src << PVR_TA_PM2_SRCBLEND_SHIFT) & PVR_TA_PM2_SRCBLEND_MASK; @@ -259,51 +290,52 @@ dst->mode2 |= (src->gen.color_clamp << PVR_TA_PM2_CLAMP_SHIFT) & PVR_TA_PM2_CLAMP_MASK; dst->mode2 |= (src->gen.alpha << PVR_TA_PM2_ALPHA_SHIFT) & PVR_TA_PM2_ALPHA_MASK; - assert_msg(src->txr.base != NULL, "Sprites must be textured"); + if(src->txr.enable == PVR_TEXTURE_DISABLE) { + dst->mode3 = 0; + } + else { + dst->mode2 |= (src->txr.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; + dst->mode2 |= (src->txr.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; + dst->mode2 |= (src->txr.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; + dst->mode2 |= (src->txr.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; + dst->mode2 |= (src->txr.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; - dst->mode2 |= (src->txr.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; - dst->mode2 |= (src->txr.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; - dst->mode2 |= (src->txr.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; - dst->mode2 |= (src->txr.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; - dst->mode2 |= (src->txr.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; + switch (src->txr.width) { + case 8: u = 0; break; + case 16: u = 1; break; + case 32: u = 2; break; + case 64: u = 3; break; + case 128: u = 4; break; + case 256: u = 5; break; + case 512: u = 6; break; + case 1024: u = 7; break; + default: assert_msg(0, "Invalid texture U size"); u = 0; break; + } - switch (src->txr.width) { - case 8: u = 0; break; - case 16: u = 1; break; - case 32: u = 2; break; - case 64: u = 3; break; - case 128: u = 4; break; - case 256: u = 5; break; - case 512: u = 6; break; - case 1024: u = 7; break; - default: assert_msg(0, "Invalid texture U size"); u = 0; break; - } + switch (src->txr.height) { + case 8: v = 0; break; + case 16: v = 1; break; + case 32: v = 2; break; + case 64: v = 3; break; + case 128: v = 4; break; + case 256: v = 5; break; + case 512: v = 6; break; + case 1024: v = 7; break; + default: assert_msg(0, "Invalid texture V size"); v = 0; break; + } - switch (src->txr.height) { - case 8: v = 0; break; - case 16: v = 1; break; - case 32: v = 2; break; - case 64: v = 3; break; - case 128: v = 4; break; - case 256: v = 5; break; - case 512: v = 6; break; - case 1024: v = 7; break; - default: assert_msg(0, "Invalid texture V size"); v = 0; break; + dst->mode2 |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; + dst->mode2 |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; + + /* Polygon mode 3 */ + dst->mode3 = (src->txr.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; + dst->mode3 |= (src->txr.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; + + txr_base = (uint32)src->txr.base; + txr_base = (txr_base & 0x00fffff8) >> 3; + dst->mode3 |= txr_base; } - dst->mode2 |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; - dst->mode2 |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; - - /* Polygon mode 3 */ - dst->mode3 = (src->txr.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; - dst->mode3 |= (src->txr.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; - - txr_base = (uint32)src->txr.base; - txr_base = (txr_base & 0x00fffff8) >> 3; - dst->mode3 |= txr_base; - - dst->a = 1.0f; - dst->r = 1.0f; - dst->g = 1.0f; - dst->b = 1.0f; + dst->argb = 0xFFFFFFFF; + dst->oargb = 0x00000000; } Modified: kos/kernel/arch/dreamcast/include/dc/pvr.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-05-09 00:13:03 UTC (rev 636) +++ kos/kernel/arch/dreamcast/include/dc/pvr.h 2009-06-02 02:54:25 UTC (rev 637) @@ -99,6 +99,7 @@ int write; } depth; struct { + int enable; int filter; int mipmap; int mipmap_bias; @@ -265,13 +266,22 @@ } pvr_poly_hdr_t; /* Polygon header with intensity color. This is the equivalent of - pvr_poly_hdr_t, but for use with intensity color (sprites). */ + pvr_poly_hdr_t, but for use with intensity color. */ typedef struct { uint32 cmd; /* TA command */ uint32 mode1, mode2, mode3; /* mode parameters */ float a, r, g, b; /* color */ } pvr_poly_ic_hdr_t; +/* Polygon header specifically for sprites. */ +typedef struct { + uint32 cmd; /* TA command */ + uint32 mode1, mode2, mode3; /* mode parameters */ + uint32 argb; /* sprite color */ + uint32 oargb; /* offset color */ + uint32 d1, d2; /* dummies */ +} pvr_sprite_hdr_t; + /* Generic vertex type; the PVR chip itself supports many more vertex types, but this is the main one that can be used with both textured and non-textured polygons, and is fairly fast. You can find other @@ -315,6 +325,18 @@ uint32 cuv; } pvr_sprite_txr_t; +/* Untextured sprite. This vertex type is to be used with the sprite + polygon header and the sprite related commands to draw untextured + sprites (aka, quads). */ +typedef struct { + uint32 flags; + float ax, ay, az; + float bx, by, bz; + float cx, cy, cz; + float dx, dy; + uint32 d1, d2, d3, d4; +} pvr_sprite_col_t; + /* This vertex is only for modifer volumes */ typedef struct { uint32 flags; /* vertex flags */ @@ -866,9 +888,12 @@ int filtering); /* Compile a sprite context into a colored polygon header */ -void pvr_sprite_compile(pvr_poly_ic_hdr_t *dst, +void pvr_sprite_compile(pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src); +/* Create an untextured sprite context */ +void pvr_sprite_cxt_col(pvr_sprite_cxt_t *dst, pvr_list_t list); + /* Create a textured sprite context */ void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-05-09 00:14:48
|
Revision: 636 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=636&view=rev Author: ljsebald Date: 2009-05-09 00:13:03 +0000 (Sat, 09 May 2009) Log Message: ----------- Adding in timed wait on a recursive lock. Modified Paths: -------------- kos/include/kos/recursive_lock.h kos/kernel/thread/recursive_lock.c Modified: kos/include/kos/recursive_lock.h =================================================================== --- kos/include/kos/recursive_lock.h 2009-05-03 19:05:00 UTC (rev 635) +++ kos/include/kos/recursive_lock.h 2009-05-09 00:13:03 UTC (rev 636) @@ -38,6 +38,12 @@ EINTR - was interrupted */ int rlock_lock(recursive_lock_t *l); +/* Lock a recursive lock, with timeout (in milliseconds). Returns -1 on error. + EPERM - called inside an interrupt + EINTR - was interrupted + EAGIN - timed out*/ +int rlock_lock_timed(recursive_lock_t *l, int timeout); + /* Unlock a recursive lock. Returns -1 on error. EPERM - the lock is not held by the current thread */ int rlock_unlock(recursive_lock_t *l); Modified: kos/kernel/thread/recursive_lock.c =================================================================== --- kos/kernel/thread/recursive_lock.c 2009-05-03 19:05:00 UTC (rev 635) +++ kos/kernel/thread/recursive_lock.c 2009-05-09 00:13:03 UTC (rev 636) @@ -1,7 +1,7 @@ /* KallistiOS ##version## recursive_lock.c - Copyright (C) 2008 Lawrence Sebald + Copyright (C) 2008, 2009 Lawrence Sebald */ /* This file defines recursive locks. */ @@ -42,10 +42,15 @@ /* Lock a recursive lock */ int rlock_lock(recursive_lock_t *l) { + return rlock_lock_timed(l, 0); +} + +/* Lock a recursive lock, with timeout (in milliseconds) */ +int rlock_lock_timed(recursive_lock_t *l, int timeout) { int old, rv = 0; if(irq_inside_int()) { - dbglog(DBG_WARNING, "rlock_lock: called inside interrupt\n"); + dbglog(DBG_WARNING, "rlock_lock_timed: called inside interrupt\n"); errno = EPERM; return -1; } @@ -64,7 +69,7 @@ } else { /* Block until the lock isn't held any more */ - rv = genwait_wait(l, "rlock_lock", 0, NULL); + rv = genwait_wait(l, "rlock_lock_timed", timeout, NULL); if(rv < 0) { assert(errno == EINTR); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-05-03 19:05:05
|
Revision: 635 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=635&view=rev Author: ljsebald Date: 2009-05-03 19:05:00 +0000 (Sun, 03 May 2009) Log Message: ----------- Adding in a linker script to be used with GCC 4.x... The default one puts the .init segment in a rather stupid place (0x1000, I think), which of course won't work all that well. Also, this one prunes away the useless .stack segment. Modified Paths: -------------- kos/environ_base.sh Added Paths: ----------- kos/utils/ldscripts/ kos/utils/ldscripts/shlelf.xc Modified: kos/environ_base.sh =================================================================== --- kos/environ_base.sh 2009-05-02 18:43:17 UTC (rev 634) +++ kos/environ_base.sh 2009-05-03 19:05:00 UTC (rev 635) @@ -31,7 +31,7 @@ case $GCCVER in 4*) - export KOS_LDFLAGS="${KOS_LDFLAGS} -nodefaultlibs ${KOS_LIB_PATHS}" ;; + export KOS_LDFLAGS="${KOS_LDFLAGS} -T${KOS_BASE}/utils/ldscripts/shlelf.xc -nodefaultlibs ${KOS_LIB_PATHS}" ;; *) export KOS_LDFLAGS="${KOS_LDFLAGS} -nostartfiles -nostdlib ${KOS_LIB_PATHS}" ;; esac Added: kos/utils/ldscripts/shlelf.xc =================================================================== --- kos/utils/ldscripts/shlelf.xc (rev 0) +++ kos/utils/ldscripts/shlelf.xc 2009-05-03 19:05:00 UTC (rev 635) @@ -0,0 +1,227 @@ +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-shl", "elf32-shl", + "elf32-shl") +OUTPUT_ARCH(sh) +ENTRY(start) +SEARCH_DIR("/usr/local/dc-new/sh-elf/sh-elf/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = 0x8c010000); . = 0x8c010000; + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + .init : + { + KEEP (*(.init)) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + .interp : { *(.interp) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) + *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) + *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) + *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) + *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) + *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) + *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .plt : { *(.plt) } + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .sdata2 : + { + *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) + } + .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + ___ctors = .; + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ___ctors_end = .; + } + .dtors : + { + ___dtors = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ___dtors_end = .; + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + .data : + { + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + .got : { *(.got.plt) *(.got) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : + { + *(.sdata .sdata.* .gnu.linkonce.s.*) + } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + .sbss : + { + *(.dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + _end = .; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-05-02 18:43:27
|
Revision: 634 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=634&view=rev Author: ljsebald Date: 2009-05-02 18:43:17 +0000 (Sat, 02 May 2009) Log Message: ----------- Initial GCC 4.x support and various warning cleanups Modified Paths: -------------- kos/environ_base.sh kos/kernel/arch/dreamcast/fs/fs_dclsocket.c kos/kernel/arch/dreamcast/fs/fs_iso9660.c kos/kernel/arch/dreamcast/hardware/flashrom.c kos/kernel/arch/dreamcast/hardware/modem/mdata.c kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c kos/kernel/arch/dreamcast/include/dc/vmufs.h kos/kernel/arch/dreamcast/kernel/gdb_stub.c kos/kernel/arch/dreamcast/kernel/init.c kos/kernel/fs/elf.c kos/kernel/fs/fs_romdisk.c kos/kernel/libc/koslib/crtbegin.c kos/kernel/libc/koslib/crtend.c kos/kernel/net/net_arp.c kos/kernel/net/net_dhcp.c kos/kernel/net/net_icmp.h kos/kernel/net/net_ipv4.h Modified: kos/environ_base.sh =================================================================== --- kos/environ_base.sh 2009-05-01 18:55:59 UTC (rev 633) +++ kos/environ_base.sh 2009-05-02 18:43:17 UTC (rev 634) @@ -11,8 +11,6 @@ export KOS_INC_PATHS="${KOS_INC_PATHS} -I${KOS_BASE}/include \ -I${KOS_BASE}/kernel/arch/${KOS_ARCH}/include -I${KOS_BASE}/addons/include" -#export KOS_INC_PATHS_CPP="${KOS_INC_PATHS_CPP} -I${KOS_BASE}/libk++/stlport" - # "System" libraries export KOS_LIB_PATHS="-L${KOS_BASE}/lib/${KOS_ARCH} -L${KOS_BASE}/addons/lib/${KOS_ARCH}" export KOS_LIBS="-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group" @@ -28,9 +26,22 @@ export KOS_STRIP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-strip" export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_INC_PATHS} -D_arch_${KOS_ARCH} -D_arch_sub_${KOS_SUBARCH} -Wall -g -fno-builtin -fno-strict-aliasing" export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP} -fno-operator-names -fno-rtti -fno-exceptions" -#export KOS_AFLAGS="${KOS_AFLAGS}" -export KOS_LDFLAGS="${KOS_LDFLAGS} -nostartfiles -nostdlib ${KOS_LIB_PATHS}" +GCCVER="`kos-cc -v 2>&1 | tail -1 | awk '{print $3}'`" + +case $GCCVER in + 4*) + export KOS_LDFLAGS="${KOS_LDFLAGS} -nodefaultlibs ${KOS_LIB_PATHS}" ;; + *) + export KOS_LDFLAGS="${KOS_LDFLAGS} -nostartfiles -nostdlib ${KOS_LIB_PATHS}" ;; +esac + # Some extra vars based on architecture export KOS_ARCH_DIR="${KOS_BASE}/kernel/arch/${KOS_ARCH}" -export KOS_START="${KOS_ARCH_DIR}/kernel/startup.o" + +case $GCCVER in + 4*) + export KOS_START="" ;; + *) + export KOS_START="${KOS_ARCH_DIR}/kernel/startup.o" ;; +esac Modified: kos/kernel/arch/dreamcast/fs/fs_dclsocket.c =================================================================== --- kos/kernel/arch/dreamcast/fs/fs_dclsocket.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/fs/fs_dclsocket.c 2009-05-02 18:43:17 UTC (rev 634) @@ -41,23 +41,23 @@ #define PACKED __attribute__((packed)) typedef struct { - unsigned char id[4] PACKED; - unsigned int address PACKED; - unsigned int size PACKED; - unsigned char data[0] PACKED; -} command_t; + unsigned char id[4]; + unsigned int address; + unsigned int size; + unsigned char data[0]; +} PACKED command_t; typedef struct { - unsigned char id[4] PACKED; - unsigned int value0 PACKED; -} command_int_t; + unsigned char id[4]; + unsigned int value0; +} PACKED command_int_t; typedef struct { - unsigned char id[4] PACKED; - unsigned int value0 PACKED; - unsigned int value1 PACKED; - unsigned int value2 PACKED; -} command_3int_t; + unsigned char id[4]; + unsigned int value0; + unsigned int value1; + unsigned int value2; +} PACKED command_3int_t; #undef PACKED static struct { @@ -158,7 +158,7 @@ int size = strlen(NAME) + 1 + sizeof(command_t); memcpy(resp, cmd, sizeof(command_t)); - strcpy(resp->data, NAME); + strcpy((char *)resp->data, NAME); send(dcls_socket, pktbuf, size, 0); } @@ -230,7 +230,7 @@ } memcpy(pktbuf, "DC16", 4); - strcpy(pktbuf + 4, fn); + strcpy((char *)(pktbuf + 4), fn); send(dcls_socket, pktbuf, 5 + strlen(realfn), 0); @@ -268,7 +268,7 @@ memcpy(cmd->id, "DC04", 4); cmd->address = htonl(dcload_mode); /* Open flags */ cmd->size = htonl(0644); /* umask */ - strcpy(cmd->data, fn); + strcpy((char *)cmd->data, fn); send(dcls_socket, pktbuf, sizeof(command_t) + strlen(fn) + 1, 0); dcls_recv_loop(); @@ -472,7 +472,7 @@ memcpy(cmd2->id, "DC13", 4); cmd2->address = htonl((uint32) &filestat); cmd2->size = htonl(sizeof(dcload_stat_t)); - strcpy(cmd2->data, fn); + strcpy((char *)cmd2->data, fn); send(dcls_socket, cmd2, sizeof(command_t) + strlen(fn) + 1, 0); @@ -511,8 +511,8 @@ } memcpy(pktbuf, "DC07", 4); - strcpy(pktbuf + 4, fn1); - strcpy(pktbuf + 5 + len1, fn2); + strcpy((char *)(pktbuf + 4), fn1); + strcpy((char *)(pktbuf + 5 + len1), fn2); send(dcls_socket, pktbuf, 6 + len1 + len2, 0); @@ -520,7 +520,7 @@ if(retval == 0) { memcpy(pktbuf, "DC08", 4); - strcpy(pktbuf + 4, fn1); + strcpy((char *)(pktbuf + 4), fn1); send(dcls_socket, pktbuf, len1 + 5, 0); @@ -546,7 +546,7 @@ } memcpy(pktbuf, "DC08", 4); - strcpy(pktbuf + 4, fn); + strcpy((char *)(pktbuf + 4), fn); send(dcls_socket, pktbuf, len, 0); @@ -579,7 +579,7 @@ memcpy(cmd->id, "DC13", 4); cmd->address = htonl((uint32) &filestat); cmd->size = htonl(sizeof(struct stat)); - strcpy(cmd->data, fn); + strcpy((char *)(cmd->data), fn); send(dcls_socket, cmd, sizeof(command_t) + strlen(fn) + 1, 0); Modified: kos/kernel/arch/dreamcast/fs/fs_iso9660.c =================================================================== --- kos/kernel/arch/dreamcast/fs/fs_iso9660.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/fs/fs_iso9660.c 2009-05-02 18:43:17 UTC (rev 634) @@ -404,7 +404,7 @@ /* If this is a Joliet CD, then UCSify the name */ if (joliet) - utf2ucs(ucsname, fn); + utf2ucs(ucsname, (uint8 *)fn); while (size_left > 0) { c = biread(dir_extent); @@ -417,7 +417,7 @@ /* Try the Joliet filename if the CD is a Joliet disc */ if (joliet) { - if (!ucscompare(de->name, ucsname, de->name_len)) { + if (!ucscompare((uint8 *)de->name, ucsname, de->name_len)) { if (!((dir << 1) ^ de->flags)) return de; } @@ -434,9 +434,9 @@ pnt++; len--; } while ((len >= 4) && ((pnt[3] == 1) || (pnt[3] == 2))) { - if (strncmp(pnt, "NM", 2) == 0) { + if (strncmp((char *)pnt, "NM", 2) == 0) { rrnamelen = pnt[2] - 5; - strncpy(rrname, pnt+5, rrnamelen); + strncpy(rrname, (char *)(pnt+5), rrnamelen); rrname[rrnamelen] = 0; } len -= pnt[2]; @@ -768,7 +768,7 @@ } if (joliet) { - ucs2utfn(fh[fd].dirent.name, de->name, de->name_len); + ucs2utfn((uint8 *)fh[fd].dirent.name, (uint8 *)de->name, de->name_len); } else { /* Fill out the VFS dirent */ strncpy(fh[fd].dirent.name, de->name, de->name_len); @@ -782,8 +782,8 @@ pnt++; len--; } while ((len >= 4) && ((pnt[3] == 1) || (pnt[3] == 2))) { - if (strncmp(pnt, "NM", 2) == 0) { - strncpy(fh[fd].dirent.name, pnt+5, pnt[2] - 5); + if (strncmp((char *)pnt, "NM", 2) == 0) { + strncpy(fh[fd].dirent.name, (char *)(pnt+5), pnt[2] - 5); fh[fd].dirent.name[pnt[2] - 5] = 0; } len -= pnt[2]; Modified: kos/kernel/arch/dreamcast/hardware/flashrom.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/flashrom.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/hardware/flashrom.c 2009-05-02 18:43:17 UTC (rev 634) @@ -644,7 +644,7 @@ /* Grab block 0x83 */ if(flashrom_get_block(FLASHROM_PT_BLOCK_1, FLASHROM_B1_PW_SETTINGS_4, buffer) >= 0) { /* The modem init string continues at the start of this block. */ - strncpy(out->modem_init + 30, isp->b83.modem_str2, 2); + strncpy(out->modem_init + 30, (char *)isp->b83.modem_str2, 2); out->modem_init[32] = '\0'; /* Copy out the area code next. */ Modified: kos/kernel/arch/dreamcast/hardware/modem/mdata.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/modem/mdata.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/hardware/modem/mdata.c 2009-05-02 18:43:17 UTC (rev 634) @@ -381,7 +381,7 @@ if (w < 0) dbglog(DBG_ERROR, "modem_dial: unknown DTMF symbol '%c'\n", digits[i]); else - writeToChainBuffer(txBuffer, &w, 1); + writeToChainBuffer(txBuffer, (unsigned char *)&w, 1); } primeBuffer = 1; Modified: kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/hardware/network/broadband_adapter.c 2009-05-02 18:43:17 UTC (rev 634) @@ -86,7 +86,7 @@ static int gaps_detect() { char str[16]; - g2_read_block_8(str, 0xa1001400, 16); + g2_read_block_8((uint8 *)str, 0xa1001400, 16); if (!strncmp(str, "GAPSPCI_BRIDGE_2", 16)) return 0; else Modified: kos/kernel/arch/dreamcast/include/dc/vmufs.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/vmufs.h 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/include/dc/vmufs.h 2009-05-02 18:43:17 UTC (rev 634) @@ -16,46 +16,46 @@ #define __packed__ __attribute__((packed)) /** BCD timestamp, used several places below */ typedef struct { - uint8 cent __packed__; - uint8 year __packed__; - uint8 month __packed__; - uint8 day __packed__; - uint8 hour __packed__; - uint8 min __packed__; - uint8 sec __packed__; - uint8 dow __packed__; /* Day of week (0 = monday, etc) */ -} vmu_timestamp_t; + uint8 cent; + uint8 year; + uint8 month; + uint8 day; + uint8 hour; + uint8 min; + uint8 sec; + uint8 dow; /* Day of week (0 = monday, etc) */ +} __packed__ vmu_timestamp_t; /** Root block layout */ typedef struct { - uint8 magic[16] __packed__; /*< All should contain 0x55 */ - uint8 use_custom __packed__; /*< 0 = standard, 1 = custom */ - uint8 custom_color[4] __packed__; /*< blue, green, red, alpha */ - uint8 pad1[27] __packed__; /*< All zeros */ - vmu_timestamp_t timestamp __packed__; /*< BCD timestamp */ - uint8 pad2[8] __packed__; /*< All zeros */ - uint8 unk1[6] __packed__; /*< ??? */ - uint16 fat_loc __packed__; /*< FAT location */ - uint16 fat_size __packed__; /*< FAT size in blocks */ - uint16 dir_loc __packed__; /*< Directory location */ - uint16 dir_size __packed__; /*< Directory size in blocks */ - uint16 icon_shape __packed__; /*< Icon shape for this VMS */ - uint16 blk_cnt __packed__; /*< Number of user blocks */ - uint8 unk2[430] __packed__; /*< ??? */ -} vmu_root_t; + uint8 magic[16]; /*< All should contain 0x55 */ + uint8 use_custom; /*< 0 = standard, 1 = custom */ + uint8 custom_color[4]; /*< blue, green, red, alpha */ + uint8 pad1[27]; /*< All zeros */ + vmu_timestamp_t timestamp; /*< BCD timestamp */ + uint8 pad2[8]; /*< All zeros */ + uint8 unk1[6]; /*< ??? */ + uint16 fat_loc ; /*< FAT location */ + uint16 fat_size; /*< FAT size in blocks */ + uint16 dir_loc; /*< Directory location */ + uint16 dir_size; /*< Directory size in blocks */ + uint16 icon_shape; /*< Icon shape for this VMS */ + uint16 blk_cnt; /*< Number of user blocks */ + uint8 unk2[430]; /*< ??? */ +} __packed__ vmu_root_t; /** Directory entries, 32 bytes each */ typedef struct { - uint8 filetype __packed__; /*< 0x00 = no file; 0x33 = data; 0xcc = a game */ - uint8 copyprotect __packed__; /*< 0x00 = copyable; 0xff = copy protected */ - uint16 firstblk __packed__; /*< Location of the first block in the file */ - char filename[12] __packed__; /*< Note: there is no null terminator */ - vmu_timestamp_t timestamp __packed__; /*< File time */ - uint16 filesize __packed__; /*< Size of the file in blocks */ - uint16 hdroff __packed__; /*< Offset of header, in blocks from start of file */ - uint8 dirty __packed__; /*< See header notes */ - uint8 pad1[3] __packed__; /*< All zeros */ -} vmu_dir_t; + uint8 filetype; /*< 0x00 = no file; 0x33 = data; 0xcc = a game */ + uint8 copyprotect; /*< 0x00 = copyable; 0xff = copy protected */ + uint16 firstblk; /*< Location of the first block in the file */ + char filename[12]; /*< Note: there is no null terminator */ + vmu_timestamp_t timestamp; /*< File time */ + uint16 filesize; /*< Size of the file in blocks */ + uint16 hdroff; /*< Offset of header, in blocks from start of file */ + uint8 dirty; /*< See header notes */ + uint8 pad1[3]; /*< All zeros */ +} __packed__ vmu_dir_t; #undef __packed__ /* Notes about the "dirty" field on vmu_dir_t :) Modified: kos/kernel/arch/dreamcast/kernel/gdb_stub.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/gdb_stub.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/kernel/gdb_stub.c 2009-05-02 18:43:17 UTC (rev 634) @@ -389,7 +389,7 @@ static unsigned char * getpacket (void) { - unsigned char *buffer = &remcomInBuffer[0]; + unsigned char *buffer = (unsigned char *)(&remcomInBuffer[0]); unsigned char checksum; unsigned char xmitcsum; int count; @@ -766,7 +766,7 @@ while (1) { remcomOutBuffer[0] = 0; - ptr = getpacket (); + ptr = (char *)getpacket (); switch (*ptr++) { Modified: kos/kernel/arch/dreamcast/kernel/init.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/init.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/arch/dreamcast/kernel/init.c 2009-05-02 18:43:17 UTC (rev 634) @@ -23,6 +23,12 @@ void _atexit_call_all(); +#if __GNUC__ >= 4 +void init(void); +void fini(void); +void __verify_newlib_patch(); +#endif + /* Ditto */ int main(int argc, char **argv); @@ -173,7 +179,9 @@ int rv; /* Ensure that we pull in crtend.c in the linking process */ +#if __GNUC__ < 4 __crtend_pullin(); +#endif /* Ensure that UBC is not enabled from a previous session */ ubc_disable_all(); @@ -185,7 +193,12 @@ arch_auto_init(); /* Run ctors */ +#if __GNUC__ < 4 arch_ctors(); +#else + __verify_newlib_patch(); + init(); +#endif /* Call the user's main function */ rv = main(0, NULL); @@ -207,7 +220,12 @@ void arch_shutdown() { /* Run dtors */ _atexit_call_all(); + +#if __GNUC__ < 4 arch_dtors(); +#else + fini(); +#endif dbglog(DBG_CRITICAL, "arch: shutting down kernel\n"); Modified: kos/kernel/fs/elf.c =================================================================== --- kos/kernel/fs/elf.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/fs/elf.c 2009-05-02 18:43:17 UTC (rev 634) @@ -83,7 +83,7 @@ /* Header is at the front */ hdr = (struct elf_hdr_t *)(img+0); - if (hdr->ident[0] != 0x7f || strncmp(hdr->ident+1, "ELF", 3)) { + if (hdr->ident[0] != 0x7f || strncmp((char *)hdr->ident+1, "ELF", 3)) { dbglog(DBG_ERROR, "elf_load: file is not a valid ELF file\n"); hdr->ident[4] = 0; dbglog(DBG_ERROR, " hdr->ident is %d/%s\n", hdr->ident[0], hdr->ident+1); Modified: kos/kernel/fs/fs_romdisk.c =================================================================== --- kos/kernel/fs/fs_romdisk.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/fs/fs_romdisk.c 2009-05-02 18:43:17 UTC (rev 634) @@ -467,7 +467,7 @@ /* Check the image and print some info about it */ hdr = (const romdisk_hdr_t *)img; - if (strncmp(img, "-rom1fs-", 8)) { + if (strncmp((char *)img, "-rom1fs-", 8)) { dbglog(DBG_ERROR, "Rom disk image at %p is not a ROMFS image\n", img); return -1; } else { Modified: kos/kernel/libc/koslib/crtbegin.c =================================================================== --- kos/kernel/libc/koslib/crtbegin.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/libc/koslib/crtbegin.c 2009-05-02 18:43:17 UTC (rev 634) @@ -8,6 +8,8 @@ FreeBSD crtbegin.c code. Note that the default linker scripts for GCC will automatically put our ctors at the front of the list. */ +#if __GNUC__ < 4 + #include <arch/types.h> /* Here we gain access to the ctor and dtor sections of the program by @@ -43,3 +45,5 @@ (**fpp)(); } +#endif /* __GNUC__ < 4 */ + Modified: kos/kernel/libc/koslib/crtend.c =================================================================== --- kos/kernel/libc/koslib/crtend.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/libc/koslib/crtend.c 2009-05-02 18:43:17 UTC (rev 634) @@ -8,6 +8,8 @@ FreeBSD crtend.c code. Note that the default linker scripts for GCC will automatically put our ctors at the end of the list. */ +#if __GNUC__ < 4 + #include <sys/cdefs.h> /* Here we gain access to the ctor and dtor sections of the program by @@ -23,3 +25,4 @@ (void)dtor_list; } +#endif /* __GNUC__ < 4 */ Modified: kos/kernel/net/net_arp.c =================================================================== --- kos/kernel/net/net_arp.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/net/net_arp.c 2009-05-02 18:43:17 UTC (rev 634) @@ -22,16 +22,16 @@ /* ARP Packet Structre */ #define packed __attribute__((packed)) typedef struct { - uint8 hw_type[2] packed; - uint8 pr_type[2] packed; - uint8 hw_size packed; - uint8 pr_size packed; - uint8 opcode[2] packed; - uint8 hw_send[6] packed; - uint8 pr_send[4] packed; - uint8 hw_recv[6] packed; - uint8 pr_recv[6] packed; -} arp_pkt_t; + uint8 hw_type[2]; + uint8 pr_type[2]; + uint8 hw_size; + uint8 pr_size; + uint8 opcode[2]; + uint8 hw_send[6]; + uint8 pr_send[4]; + uint8 hw_recv[6]; + uint8 pr_recv[6]; +} packed arp_pkt_t; #undef packed /**************************************************************************/ Modified: kos/kernel/net/net_dhcp.c =================================================================== --- kos/kernel/net/net_dhcp.c 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/net/net_dhcp.c 2009-05-02 18:43:17 UTC (rev 634) @@ -77,7 +77,7 @@ /* Host Name: Dreamcast */ req->options[pos++] = DHCP_OPTION_HOST_NAME; req->options[pos++] = 10; /* Length = 10 */ - strcpy(req->options + pos, "KallistiOS"); + strcpy((char *)req->options + pos, "KallistiOS"); pos += 10; /* Client Identifier: The network adapter's MAC address */ Modified: kos/kernel/net/net_icmp.h =================================================================== --- kos/kernel/net/net_icmp.h 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/net/net_icmp.h 2009-05-02 18:43:17 UTC (rev 634) @@ -17,11 +17,11 @@ #define packed __attribute__((packed)) typedef struct { - uint8 type packed; - uint8 code packed; - uint16 checksum packed; - uint8 misc[4] packed; -} icmp_hdr_t; + uint8 type; + uint8 code; + uint16 checksum; + uint8 misc[4]; +} packed icmp_hdr_t; #undef packed int net_icmp_input(netif_t *src, ip_hdr_t *ih, const uint8 *data, int size); Modified: kos/kernel/net/net_ipv4.h =================================================================== --- kos/kernel/net/net_ipv4.h 2009-05-01 18:55:59 UTC (rev 633) +++ kos/kernel/net/net_ipv4.h 2009-05-02 18:43:17 UTC (rev 634) @@ -11,36 +11,36 @@ /* These structs are from AndrewK's dcload-ip. */ #define packed __attribute__((packed)) typedef struct { - uint8 dest[6] packed; - uint8 src[6] packed; - uint8 type[2] packed; -} eth_hdr_t; + uint8 dest[6]; + uint8 src[6]; + uint8 type[2]; +} packed eth_hdr_t; typedef struct { - uint8 version_ihl packed; - uint8 tos packed; - uint16 length packed; - uint16 packet_id packed; - uint16 flags_frag_offs packed; - uint8 ttl packed; - uint8 protocol packed; - uint16 checksum packed; - uint32 src packed; - uint32 dest packed; -} ip_hdr_t; + uint8 version_ihl; + uint8 tos; + uint16 length; + uint16 packet_id; + uint16 flags_frag_offs; + uint8 ttl; + uint8 protocol; + uint16 checksum; + uint32 src; + uint32 dest; +} packed ip_hdr_t; typedef struct { - uint32 src_addr packed; - uint32 dst_addr packed; - uint8 zero packed; - uint8 proto packed; - uint16 length packed; - uint16 src_port packed; - uint16 dst_port packed; - uint16 hdrlength packed; - uint16 checksum packed; - uint8 data[1] packed; -} ip_pseudo_hdr_t; + uint32 src_addr; + uint32 dst_addr; + uint8 zero; + uint8 proto; + uint16 length; + uint16 src_port; + uint16 dst_port; + uint16 hdrlength; + uint16 checksum; + uint8 data[1]; +} packed ip_pseudo_hdr_t; #undef packed uint16 net_ipv4_checksum(const uint8 *data, int bytes); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-05-01 18:56:00
|
Revision: 633 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=633&view=rev Author: ljsebald Date: 2009-05-01 18:55:59 +0000 (Fri, 01 May 2009) Log Message: ----------- Remove two variables from thread.h that are actually static in thread.c. Modified Paths: -------------- kos/include/kos/thread.h Modified: kos/include/kos/thread.h =================================================================== --- kos/include/kos/thread.h 2009-04-30 23:19:39 UTC (rev 632) +++ kos/include/kos/thread.h 2009-05-01 18:55:59 UTC (rev 633) @@ -128,12 +128,6 @@ #define THD_MODE_COOP 0 #define THD_MODE_PREEMPT 1 -/* Thread list; note: do not manipulate directly */ -extern struct ktlist thd_list; - -/* Run queue; note: do not manipulate directly */ -extern struct ktqueue run_queue; - /* The currently executing thread */ extern kthread_t *thd_current; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-04-30 23:19:40
|
Revision: 632 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=632&view=rev Author: ljsebald Date: 2009-04-30 23:19:39 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Added missing __END_DECLS Modified Paths: -------------- kos/include/kos/once.h Modified: kos/include/kos/once.h =================================================================== --- kos/include/kos/once.h 2009-04-30 14:08:56 UTC (rev 631) +++ kos/include/kos/once.h 2009-04-30 23:19:39 UTC (rev 632) @@ -23,4 +23,6 @@ EINTR - was interrupted */ int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)); +__END_DECLS + #endif /* !__KOS_ONCE_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-04-30 14:08:58
|
Revision: 631 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=631&view=rev Author: ljsebald Date: 2009-04-30 14:08:56 +0000 (Thu, 30 Apr 2009) Log Message: ----------- Adding in thread-local storage support. Modified Paths: -------------- kos/doc/CHANGELOG kos/examples/dreamcast/basic/threading/Makefile kos/include/kos/thread.h kos/include/kos.h kos/kernel/thread/Makefile kos/kernel/thread/thread.c Added Paths: ----------- kos/examples/dreamcast/basic/threading/tls/ kos/examples/dreamcast/basic/threading/tls/Makefile kos/examples/dreamcast/basic/threading/tls/tls_test.c kos/include/kos/tls.h kos/kernel/thread/tls.c Modified: kos/doc/CHANGELOG =================================================================== --- kos/doc/CHANGELOG 2009-04-29 18:08:33 UTC (rev 630) +++ kos/doc/CHANGELOG 2009-04-30 14:08:56 UTC (rev 631) @@ -179,6 +179,8 @@ - *** Added an implementation of DHCP to the network stack [LS] - DC Added Dreameye driver that is capable of fetching stored images from the device. [LS] +- *** Added kthread_once function (think pthread_once) [LS] +- *** Added pthreads-like thread-local storage [LS] KallistiOS version 1.2.0 ----------------------------------------------- - DC Fix to use DCARM7_CFLAGS when compiling ARM driver [Christian Groessler == CG] Modified: kos/examples/dreamcast/basic/threading/Makefile =================================================================== --- kos/examples/dreamcast/basic/threading/Makefile 2009-04-29 18:08:33 UTC (rev 630) +++ kos/examples/dreamcast/basic/threading/Makefile 2009-04-30 14:08:56 UTC (rev 631) @@ -9,16 +9,19 @@ $(KOS_MAKE) -C rwsem $(KOS_MAKE) -C recursive_lock $(KOS_MAKE) -C once + $(KOS_MAKE) -C tls clean: $(KOS_MAKE) -C general clean $(KOS_MAKE) -C rwsem clean $(KOS_MAKE) -C recursive_lock clean $(KOS_MAKE) -C once clean + $(KOS_MAKE) -C tls clean dist: $(KOS_MAKE) -C general dist $(KOS_MAKE) -C rwsem dist $(KOS_MAKE) -C recursive_lock dist $(KOS_MAKE) -C once dist + $(KOS_MAKE) -C tls dist Added: kos/examples/dreamcast/basic/threading/tls/Makefile =================================================================== --- kos/examples/dreamcast/basic/threading/tls/Makefile (rev 0) +++ kos/examples/dreamcast/basic/threading/tls/Makefile 2009-04-30 14:08:56 UTC (rev 631) @@ -0,0 +1,30 @@ +# KallistiOS ##version## +# +# basic/threading/tls/Makefile +# Copyright (C) 2009 Lawrence Sebald +# + +all: rm-elf tls_test.elf + +include $(KOS_BASE)/Makefile.rules + +OBJS = tls_test.o + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f tls_test.elf + +tls_test.elf: $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o tls_test.elf $(KOS_START) \ + $(OBJS) $(DATAOBJS) $(OBJEXTRA) $(KOS_LIBS) + + +run: tls_test.elf + $(KOS_LOADER) tls_test.elf + +dist: + rm -f $(OBJS) + $(KOS_STRIP) tls_test.elf + Added: kos/examples/dreamcast/basic/threading/tls/tls_test.c =================================================================== --- kos/examples/dreamcast/basic/threading/tls/tls_test.c (rev 0) +++ kos/examples/dreamcast/basic/threading/tls/tls_test.c 2009-04-30 14:08:56 UTC (rev 631) @@ -0,0 +1,105 @@ +/* KallistiOS ##version## + + tls_test.c + Copyright (C) 2009 Lawrence Sebald + +*/ + +/* This program is a test for thread-local storage added in KOS 1.3.0. */ + +#include <stdio.h> +#include <stdlib.h> +#include <kos/thread.h> +#include <kos/once.h> +#include <kos/tls.h> + +#include <arch/arch.h> +#include <dc/maple.h> +#include <dc/maple/controller.h> + +#define UNUSED __attribute__((unused)) + +kthread_once_t once = KTHREAD_ONCE_INIT; +kthread_key_t key1, key2; + +void destructor(void *data) { + printf("Destroying %d\n", (int)data); +} + +void once_func(void) { + if(kthread_key_create(&key2, &destructor)) { + printf("Error in calling kthread_key_create\n"); + } +} + +void thd_func(void *param UNUSED) { + kthread_t *cur = thd_get_current(); + void *data; + + printf("Thd %d: Reading key 1\n", cur->tid); + data = kthread_getspecific(key1); + printf("Thd %d: kthread_getspecific returned %p (should be NULL)\n", + cur->tid, data); + + printf("Thd %d: Will create key 2, if its not created\n", cur->tid); + kthread_once(&once, &once_func); + + printf("Thd %d: Writing to key 2\n", cur->tid); + if(kthread_setspecific(key2, (void *)cur->tid)) { + printf("Error in kthread_setspecific!!!\n"); + thd_exit(); + } + + if(cur->tid & 0x01) { + printf("Thd %d: sleeping...\n", cur->tid); + thd_sleep(200); + } + + printf("Thd %d: Reading key 2\n", cur->tid); + data = kthread_getspecific(key2); + printf("Thd %d: kthread_getspecific returned %d (should be %d)\n", cur->tid, + (int)data, cur->tid); +} + +KOS_INIT_FLAGS(INIT_DEFAULT); + +int main(int argc, char *argv[]) { + kthread_t *thds[2]; + void *data; + + cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, + arch_exit); + + printf("KallistiOS TLS test program\n"); + + printf("Main thread: Creating key 1\n"); + if(kthread_key_create(&key1, NULL)) { + printf("Error in creating key 1\n"); + exit(-1); + } + + printf("Main thread: Setting key 1 to 0xDEADBEEF\n"); + kthread_setspecific(key1, (void *)0xDEADBEEF); + data = kthread_getspecific(key1); + printf("Main thread: Key 1 value: %p\n", data); + + /* Create the threads. */ + printf("Main therad: Creating 2 threads\n"); + thds[0] = thd_create(&thd_func, NULL); + thds[1] = thd_create(&thd_func, NULL); + + printf("Main thread: Waiting for the threads to finish\n"); + thd_wait(thds[0]); + thd_wait(thds[1]); + + data = kthread_getspecific(key1); + printf("Main thread: Key 1 value: %p\n", data); + + printf("Main thread: Removing keys\n"); + kthread_key_delete(key1); + kthread_key_delete(key2); + + printf("Test finished\n"); + + return 0; +} Modified: kos/include/kos/thread.h =================================================================== --- kos/include/kos/thread.h 2009-04-29 18:08:33 UTC (rev 630) +++ kos/include/kos/thread.h 2009-04-30 14:08:56 UTC (rev 631) @@ -2,6 +2,7 @@ include/kos/thread.h Copyright (C)2000,2001,2002,2003 Dan Potter + Copyright (C) 2009 Lawrence Sebald */ @@ -11,6 +12,7 @@ #include <sys/cdefs.h> __BEGIN_DECLS +#include <kos/tls.h> #include <arch/types.h> #include <arch/irq.h> #include <arch/arch.h> @@ -21,6 +23,23 @@ #define PRIO_MAX 4096 #define PRIO_DEFAULT 10 +/* Thread-local storage key-value pair. */ +typedef struct kthread_tls_kv { + /* List handle. */ + LIST_ENTRY(kthread_tls_kv) kv_list; + + /* The key associated with this data. */ + kthread_key_t key; + + /* The value of the data. */ + void *data; + + /* Optional destructor for the key. */ + void (*destructor)(void *); +} kthread_tls_kv_t; + +LIST_HEAD(kthread_tls_kv_list, kthread_tls_kv); + /* Pre-define list/queue types */ struct kthread; TAILQ_HEAD(ktqueue, kthread); @@ -87,6 +106,9 @@ /* Our re-ent struct for newlib */ struct _reent thd_reent; + + /* Thread-local storage */ + struct kthread_tls_kv_list tls_list; } kthread_t; /* Thread flag values */ Added: kos/include/kos/tls.h =================================================================== --- kos/include/kos/tls.h (rev 0) +++ kos/include/kos/tls.h 2009-04-30 14:08:56 UTC (rev 631) @@ -0,0 +1,53 @@ +/* KallistiOS ##version## + + include/kos/tls.h + Copyright (C) 2009 Lawrence Sebald + +*/ + +/* This file defines methods for accessing thread-local storage, added in KOS + 1.3.0. */ + +#ifndef __KOS_TLS_H +#define __KOS_TLS_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +/* Thread-local storage key type. */ +typedef int kthread_key_t; + +/* Retrieve the next key value (i.e, what key the next kthread_key_create will + use). */ +kthread_key_t kthread_key_next(); + +/* Create a new TLS key. Returns non-zero on failure. + EPERM - called inside an interrupt and another call is in progress + ENOMEM - out of memory */ +int kthread_key_create(kthread_key_t *key, void (*destructor)(void *)); + +/* Get the value stored for a given TLS key. Returns NULL if the key is not + valid or not set in the current thread. */ +void *kthread_getspecific(kthread_key_t key); + +/* Set the value for a given TLS key. Returns non-zero on failure. + EINVAL - the key is not valid + ENOMEM - out of memory + EPERM - called inside an interrupt and another call is in progress */ +int kthread_setspecific(kthread_key_t key, const void *value); + +/* Delete a TLS key, removing all threads' values for the given key. This does + not call any destructors. Returns non-zero on failure. + EINVAL - the key is not valid + EPERM - unsafe to utilize free */ +int kthread_key_delete(kthread_key_t key); + +/* Delete the destructor for a given key. */ +void kthread_key_delete_destructor(kthread_key_t key); + +int kthread_tls_init(); +void kthread_tls_shutdown(); + +__END_DECLS + +#endif /* __KOS_TLS_H */ Modified: kos/include/kos.h =================================================================== --- kos/include/kos.h 2009-04-29 18:08:33 UTC (rev 630) +++ kos/include/kos.h 2009-04-30 14:08:56 UTC (rev 631) @@ -31,6 +31,7 @@ #include <kos/rwsem.h> #include <kos/recursive_lock.h> #include <kos/once.h> +#include <kos/tls.h> #include <kos/mutex.h> #include <kos/cond.h> #include <kos/genwait.h> Modified: kos/kernel/thread/Makefile =================================================================== --- kos/kernel/thread/Makefile 2009-04-29 18:08:33 UTC (rev 630) +++ kos/kernel/thread/Makefile 2009-04-30 14:08:56 UTC (rev 631) @@ -5,7 +5,7 @@ # OBJS = sem.o cond.o mutex.o genwait.o -OBJS += thread.o rwsem.o recursive_lock.o once.o +OBJS += thread.o rwsem.o recursive_lock.o once.o tls.o SUBDIRS = include $(KOS_BASE)/Makefile.prefab Modified: kos/kernel/thread/thread.c =================================================================== --- kos/kernel/thread/thread.c 2009-04-29 18:08:33 UTC (rev 630) +++ kos/kernel/thread/thread.c 2009-04-30 14:08:56 UTC (rev 631) @@ -10,6 +10,7 @@ #include <malloc.h> #include <stdio.h> #include <reent.h> +#include <errno.h> #include <kos/thread.h> #include <kos/sem.h> #include <kos/rwsem.h> @@ -194,6 +195,22 @@ /* Terminate the current thread */ void thd_exit() { + kthread_tls_kv_t *i, *i2; + + /* Clean up any thread-local data. */ + LIST_FOREACH(i, &thd_current->tls_list, kv_list) { + if(i->destructor) { + i->destructor(i->data); + } + } + + i = LIST_FIRST(&thd_current->tls_list); + while(i != NULL) { + i2 = LIST_NEXT(i, kv_list); + free(i); + i = i2; + } + /* Call Dr. Kevorkian; after this executes we could be killed at any time. */ thd_current->state = STATE_ZOMBIE; @@ -306,6 +323,9 @@ _REENT_INIT_PTR((&(nt->thd_reent))); + /* Initialize thread-local storage. */ + LIST_INIT(&nt->tls_list); + /* Insert it into the thread list */ LIST_INSERT_HEAD(&thd_list, nt, t_list); @@ -719,6 +739,47 @@ return old; } +/* Delete a TLS key. Note that currently this doesn't prevent you from reusing + the key after deletion. This seems ok, as the pthreads standard states that + using the key after deletion results in "undefined behavior". + XXXX: This should really be in tls.c, but we need the list of threads to go + through, so it ends up here instead. */ +int kthread_key_delete(kthread_key_t key) { + int old = irq_disable(); + kthread_t *cur; + kthread_tls_kv_t *i; + + /* Make sure the key is valid. */ + if(key >= kthread_key_next() || key < 1) { + irq_restore(old); + errno = EINVAL; + return -1; + } + + /* Make sure we can actually use free below. */ + if(!malloc_irq_safe()) { + irq_restore(old); + errno = EPERM; + return -1; + } + + /* Go through each thread searching for (and removing) the data. */ + LIST_FOREACH(cur, &thd_list, t_list) { + LIST_FOREACH(i, &cur->tls_list, kv_list) { + if(i->key == key) { + LIST_REMOVE(i, kv_list); + free(i); + break; + } + } + } + + kthread_key_delete_destructor(key); + + irq_restore(old); + return 0; +} + /*****************************************************************************/ /* Init/shutdown */ @@ -745,6 +806,9 @@ /* Start off with no "current" thread */ thd_current = NULL; + /* Init thread-local storage. */ + kthread_tls_init(); + /* Setup a kernel task for the currently running "main" thread */ kern = thd_create(NULL, NULL); strcpy(kern->label, "[kernel]"); @@ -817,6 +881,8 @@ cond_shutdown(); genwait_shutdown(); + kthread_tls_shutdown(); + /* Not running */ thd_mode = THD_MODE_NONE; Added: kos/kernel/thread/tls.c =================================================================== --- kos/kernel/thread/tls.c (rev 0) +++ kos/kernel/thread/tls.c 2009-04-30 14:08:56 UTC (rev 631) @@ -0,0 +1,182 @@ +/* KallistiOS ##version## + + kernel/thread/tls.c + Copyright (C) 2009 Lawrence Sebald +*/ + +/* This file defines methods for accessing thread-local storage, added in KOS + 1.3.0. */ + +#include <stdlib.h> +#include <assert.h> +#include <errno.h> +#include <malloc.h> + +#include <kos/tls.h> +#include <kos/thread.h> +#include <arch/irq.h> +#include <arch/spinlock.h> + +static spinlock_t mutex = SPINLOCK_INITIALIZER; +static kthread_key_t next_key = 1; + +typedef struct kthread_tls_dest { + /* List handle */ + LIST_ENTRY(kthread_tls_dest) dest_list; + + /* The key */ + kthread_key_t key; + + /* Destructor for the key */ + void (*destructor)(void *); +} kthread_tls_dest_t; + +LIST_HEAD(kthread_tls_dest_list, kthread_tls_dest); + +static struct kthread_tls_dest_list dest_list; + +/* What is the next key that will be given out? */ +kthread_key_t kthread_key_next() { + return next_key; +} + +typedef void (*destructor)(void *); + +/* Get the destructor for a given key. */ +static destructor kthread_key_get_destructor(kthread_key_t key) { + kthread_tls_dest_t *i; + + LIST_FOREACH(i, &dest_list, dest_list) { + if(i->key == key) { + return i->destructor; + } + } + + return NULL; +} + +/* Delete the destructor for a given key. */ +void kthread_key_delete_destructor(kthread_key_t key) { + kthread_tls_dest_t *i; + + LIST_FOREACH(i, &dest_list, dest_list) { + if(i->key == key) { + LIST_REMOVE(i, dest_list); + free(i); + return; + } + } +} + +/* Create a new TLS key. */ +int kthread_key_create(kthread_key_t *key, void (*destructor)(void *)) { + kthread_tls_dest_t *dest; + + if(irq_inside_int() && + (spinlock_is_locked(&mutex) || !malloc_irq_safe())) { + errno = EPERM; + return -1; + } + + spinlock_lock(&mutex); + + /* Store the destructor if need be. */ + if(destructor) { + dest = (kthread_tls_dest_t *)malloc(sizeof(kthread_tls_dest_t)); + if(!dest) { + errno = ENOMEM; + spinlock_unlock(&mutex); + return -1; + } + + dest->key = next_key; + dest->destructor = destructor; + LIST_INSERT_HEAD(&dest_list, dest, dest_list); + } + + *key = next_key++; + spinlock_unlock(&mutex); + + return 0; +} + +/* Get the value stored for a given TLS key. Returns NULL if the key is invalid + or there is no data there for the current thread. */ +void *kthread_getspecific(kthread_key_t key) { + kthread_t *cur = thd_get_current(); + kthread_tls_kv_t *i; + + LIST_FOREACH(i, &cur->tls_list, kv_list) { + if(i->key == key) { + return i->data; + } + } + + return NULL; +} + +/* Set the value for a given TLS key. Returns -1 on failure. errno will be + EINVAL if the key is not valid, ENOMEM if there is no memory available to + allocate for storage, or EPERM if run inside an interrupt and the a call is + in progress already. */ +int kthread_setspecific(kthread_key_t key, const void *value) { + kthread_t *cur = thd_get_current(); + kthread_tls_kv_t *i; + + if(irq_inside_int() && spinlock_is_locked(&mutex)) { + errno = EPERM; + return -1; + } + + spinlock_lock(&mutex); + + /* Make sure the key is valid. */ + if(key >= next_key || key < 1) { + errno = EINVAL; + return -1; + } + + spinlock_unlock(&mutex); + + /* Check if we already have an entry for this key. */ + LIST_FOREACH(i, &cur->tls_list, kv_list) { + if(i->key == key) { + i->data = (void *)value; + return 0; + } + } + + /* No entry, create a new one. */ + i = (kthread_tls_kv_t *)malloc(sizeof(kthread_tls_kv_t)); + + if(!i) { + errno = ENOMEM; + return -1; + } + + i->key = key; + i->data = (void *)value; + i->destructor = kthread_key_get_destructor(key); + LIST_INSERT_HEAD(&cur->tls_list, i, kv_list); + + return 0; +} + +int kthread_tls_init() { + /* Initialize the destructor list. */ + LIST_INIT(&dest_list); + + return 0; +} + +void kthread_tls_shutdown() { + kthread_tls_dest_t *n1, *n2; + + /* Tear down the destructor list. */ + n1 = LIST_FIRST(&dest_list); + while (n1 != NULL) { + n2 = LIST_NEXT(n1, dest_list); + free(n1); + n1 = n2; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-04-29 18:08:53
|
Revision: 630 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=630&view=rev Author: ljsebald Date: 2009-04-29 18:08:33 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Adding functionality like pthread_once, along with an example for its use. Modified Paths: -------------- kos/examples/dreamcast/basic/threading/Makefile kos/include/kos.h kos/kernel/thread/Makefile Added Paths: ----------- kos/examples/dreamcast/basic/threading/once/ kos/examples/dreamcast/basic/threading/once/Makefile kos/examples/dreamcast/basic/threading/once/once_test.c kos/include/kos/once.h kos/kernel/thread/once.c Modified: kos/examples/dreamcast/basic/threading/Makefile =================================================================== --- kos/examples/dreamcast/basic/threading/Makefile 2009-04-29 03:58:46 UTC (rev 629) +++ kos/examples/dreamcast/basic/threading/Makefile 2009-04-29 18:08:33 UTC (rev 630) @@ -8,14 +8,17 @@ $(KOS_MAKE) -C general $(KOS_MAKE) -C rwsem $(KOS_MAKE) -C recursive_lock + $(KOS_MAKE) -C once clean: $(KOS_MAKE) -C general clean $(KOS_MAKE) -C rwsem clean $(KOS_MAKE) -C recursive_lock clean + $(KOS_MAKE) -C once clean dist: $(KOS_MAKE) -C general dist $(KOS_MAKE) -C rwsem dist $(KOS_MAKE) -C recursive_lock dist + $(KOS_MAKE) -C once dist Added: kos/examples/dreamcast/basic/threading/once/Makefile =================================================================== --- kos/examples/dreamcast/basic/threading/once/Makefile (rev 0) +++ kos/examples/dreamcast/basic/threading/once/Makefile 2009-04-29 18:08:33 UTC (rev 630) @@ -0,0 +1,30 @@ +# KallistiOS ##version## +# +# basic/threading/once/Makefile +# Copyright (C) 2009 Lawrence Sebald +# + +all: rm-elf once_test.elf + +include $(KOS_BASE)/Makefile.rules + +OBJS = once_test.o + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f once_test.elf + +once_test.elf: $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o once_test.elf $(KOS_START) \ + $(OBJS) $(DATAOBJS) $(OBJEXTRA) $(KOS_LIBS) + + +run: once_test.elf + $(KOS_LOADER) once_test.elf + +dist: + rm -f $(OBJS) + $(KOS_STRIP) once_test.elf + Added: kos/examples/dreamcast/basic/threading/once/once_test.c =================================================================== --- kos/examples/dreamcast/basic/threading/once/once_test.c (rev 0) +++ kos/examples/dreamcast/basic/threading/once/once_test.c 2009-04-29 18:08:33 UTC (rev 630) @@ -0,0 +1,65 @@ +/* KallistiOS ##version## + + once_test.c + Copyright (C) 2009 Lawrence Sebald + +*/ + +/* This program is a test for the kthread_once_t type added in KOS 1.3.0. A once + object is used with the kthread_once function to ensure that an initializer + function is only run once in a program (meaning multiple threads will not run + the function. */ + +#include <stdio.h> +#include <kos/thread.h> +#include <kos/once.h> + +#include <arch/arch.h> +#include <dc/maple.h> +#include <dc/maple/controller.h> + +#define UNUSED __attribute__((unused)) +#define THD_COUNT 600 + +kthread_once_t once = KTHREAD_ONCE_INIT; +int counter = 0; + +void once_func(void) { + ++counter; +} + +void thd_func(void *param UNUSED) { + kthread_t *cur = thd_get_current(); + + printf("Thd %d: Attempting to call kthread_once\n", cur->tid); + kthread_once(&once, &once_func); + printf("Thd %d: kthread_once returned\n", cur->tid); +} + +KOS_INIT_FLAGS(INIT_DEFAULT); + +int main(int argc, char *argv[]) { + int i; + kthread_t *thds[THD_COUNT]; + + cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, + arch_exit); + + printf("KallistiOS kthread_once test program\n"); + + /* Create the threads. */ + printf("Creating %d threads\n", THD_COUNT); + for(i = 0; i < THD_COUNT; ++i) { + thds[i] = thd_create(&thd_func, NULL); + } + + printf("Waiting for the threads to finish\n"); + for(i = 0; i < THD_COUNT; ++i) { + thd_wait(thds[i]); + } + + printf("Final counter value: %d (expected 1)\n", counter); + printf("Test finished\n"); + + return 0; +} Added: kos/include/kos/once.h =================================================================== --- kos/include/kos/once.h (rev 0) +++ kos/include/kos/once.h 2009-04-29 18:08:33 UTC (rev 630) @@ -0,0 +1,26 @@ +/* KallistiOS ##version## + + include/kos/once.h + Copyright (C) 2009 Lawrence Sebald + +*/ + +#ifndef __KOS_ONCE_H +#define __KOS_ONCE_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +#include <sys/queue.h> + +typedef int kthread_once_t; + +#define KTHREAD_ONCE_INIT 0 + +/* Run a function once. Returns -1 on failure. + ENOMEM - Out of memory + EPERM - called inside an interrupt + EINTR - was interrupted */ +int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)); + +#endif /* !__KOS_ONCE_H */ Modified: kos/include/kos.h =================================================================== --- kos/include/kos.h 2009-04-29 03:58:46 UTC (rev 629) +++ kos/include/kos.h 2009-04-29 18:08:33 UTC (rev 630) @@ -30,6 +30,7 @@ #include <kos/sem.h> #include <kos/rwsem.h> #include <kos/recursive_lock.h> +#include <kos/once.h> #include <kos/mutex.h> #include <kos/cond.h> #include <kos/genwait.h> Modified: kos/kernel/thread/Makefile =================================================================== --- kos/kernel/thread/Makefile 2009-04-29 03:58:46 UTC (rev 629) +++ kos/kernel/thread/Makefile 2009-04-29 18:08:33 UTC (rev 630) @@ -5,7 +5,7 @@ # OBJS = sem.o cond.o mutex.o genwait.o -OBJS += thread.o rwsem.o recursive_lock.o +OBJS += thread.o rwsem.o recursive_lock.o once.o SUBDIRS = include $(KOS_BASE)/Makefile.prefab Added: kos/kernel/thread/once.c =================================================================== --- kos/kernel/thread/once.c (rev 0) +++ kos/kernel/thread/once.c 2009-04-29 18:08:33 UTC (rev 630) @@ -0,0 +1,48 @@ +/* KallistiOS ##version## + + once.c + Copyright (C) 2009 Lawrence Sebald +*/ + +#include <malloc.h> +#include <stdio.h> +#include <assert.h> +#include <errno.h> + +#include <kos/once.h> +#include <kos/recursive_lock.h> + +/* The lock used to make sure multiple threads don't try to run the same routine + at the same time. */ +static recursive_lock_t *lock = NULL; + +int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)) { + assert(once_control); + + /* Create the lock if needed. */ + if(!lock) { + lock = rlock_create(); + + if(!lock) { + return -1; + } + } + + /* Lock the lock. */ + if(rlock_lock(lock) == -1) { + return -1; + } + + /* If the function has already been run, unlock the lock and return. */ + if(*once_control) { + rlock_unlock(lock); + return 0; + } + + /* Run the function, set the control, and unlock the lock. */ + init_routine(); + *once_control = 1; + rlock_unlock(lock); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-04-29 03:59:06
|
Revision: 629 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=629&view=rev Author: ljsebald Date: 2009-04-29 03:58:46 +0000 (Wed, 29 Apr 2009) Log Message: ----------- Fix a bug in rlock_init if malloc were to return NULL for some reason. Modified Paths: -------------- kos/kernel/thread/recursive_lock.c Modified: kos/kernel/thread/recursive_lock.c =================================================================== --- kos/kernel/thread/recursive_lock.c 2009-02-15 21:12:43 UTC (rev 628) +++ kos/kernel/thread/recursive_lock.c 2009-04-29 03:58:46 UTC (rev 629) @@ -23,6 +23,7 @@ rv = (recursive_lock_t *)malloc(sizeof(recursive_lock_t)); if(!rv) { errno = ENOMEM; + return NULL; } rv->holder = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-15 21:12:47
|
Revision: 628 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=628&view=rev Author: ljsebald Date: 2009-02-15 21:12:43 +0000 (Sun, 15 Feb 2009) Log Message: ----------- Divide up image transfers between all of the sub-devices on the Dreameye. Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/maple/dreameye.c kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h Modified: kos/kernel/arch/dreamcast/hardware/maple/dreameye.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-09 16:14:25 UTC (rev 627) +++ kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-15 21:12:43 UTC (rev 628) @@ -14,8 +14,11 @@ #include <dc/maple/dreameye.h> static int dreameye_send_get_image(maple_device_t *dev, - dreameye_state_t *state, uint8 req); + dreameye_state_t *state, uint8 req, + uint8 cnt); +static dreameye_state_t *first_state = NULL; + static void dreameye_get_image_count_cb(maple_frame_t *frame) { dreameye_state_t *de; maple_response_t *resp; @@ -54,6 +57,41 @@ genwait_wake_all(frame); } +static void dreameye_get_transfer_count_cb(maple_frame_t *frame) { + dreameye_state_t *de; + maple_response_t *resp; + uint32 *respbuf32; + uint8 *respbuf8; + + /* Unlock the frame */ + maple_frame_unlock(frame); + + /* Make sure we got a valid response */ + resp = (maple_response_t *)frame->recv_buf; + if(resp->response != MAPLE_RESPONSE_DATATRF) + return; + + respbuf32 = (uint32 *)resp->data; + respbuf8 = (uint8 *)resp->data; + if(respbuf32[0] != MAPLE_FUNC_CAMERA) + return; + + /* Update the status that was requested. */ + if(frame->dev) { + assert( (resp->data_len) == 3 ); + assert( respbuf8[4] == 0xD0 ); + assert( respbuf8[5] == 0x00 ); + assert( respbuf8[8] == DREAMEYE_GETCOND_TRANSFER_COUNT ); + + /* Update the data in the status. */ + de = (dreameye_state_t *)frame->dev->status; + de->transfer_count = (respbuf8[10] << 8) | respbuf8[11]; + } + + /* Wake up! */ + genwait_wake_all(frame); +} + int dreameye_get_image_count(maple_device_t *dev, int block) { dreameye_state_t *de; uint32 *send_buf; @@ -99,12 +137,10 @@ static void dreameye_get_image_cb(maple_frame_t *frame) { maple_device_t *dev; - dreameye_state_t *de; maple_response_t *resp; uint32 *respbuf32; uint8 *respbuf8; int len; - uint8 *tmp; /* Unlock the frame */ maple_frame_unlock(frame); @@ -113,49 +149,42 @@ return; dev = frame->dev; - de = (dreameye_state_t *)frame->dev->status; /* Make sure we got a valid response */ resp = (maple_response_t *)frame->recv_buf; if(resp->response != MAPLE_RESPONSE_DATATRF) { - de->img_transferring = -1; + first_state->img_transferring = -1; return; } respbuf32 = (uint32 *)resp->data; respbuf8 = (uint8 *)resp->data; if(respbuf32[0] != MAPLE_FUNC_CAMERA) { - de->img_transferring = -1; + first_state->img_transferring = -1; return; } len = (resp->data_len - 3) * 4; - /* Allocate space for the data. */ - tmp = (uint8 *)realloc(de->img_buf, de->img_size + len); - - if(tmp == NULL) { - de->img_transferring = -1; - return; - } - /* Copy the data. */ - memcpy(tmp + de->img_size, respbuf8 + 12, len); - de->img_buf = tmp; - de->img_size += len; - de->img_counter = respbuf8[5] + 1; + memcpy(first_state->img_buf + (int)(respbuf8[5]) * 512 , respbuf8 + 12, + len); + first_state->img_size += len; /* Check if we're done. */ if(respbuf8[4] & 0x40) { - de->img_transferring = 0; + first_state->img_transferring = 0; return; } - dreameye_send_get_image(dev, de, DREAMEYE_IMAGEREQ_CONTINUE); + if(respbuf8[5] + 5 < first_state->transfer_count) + dreameye_send_get_image(dev, first_state, DREAMEYE_IMAGEREQ_CONTINUE, + respbuf8[5] + 5); } static int dreameye_send_get_image(maple_device_t *dev, - dreameye_state_t *state, uint8 req) { + dreameye_state_t *state, uint8 req, + uint8 cnt) { uint32 *send_buf; /* Lock the frame */ @@ -167,7 +196,7 @@ send_buf = (uint32 *)dev->frame.recv_buf; send_buf[0] = MAPLE_FUNC_CAMERA; send_buf[1] = DREAMEYE_SUBCOMMAND_IMAGEREQ | (state->img_number << 8) | - (req << 16) | (state->img_counter << 24); + (req << 16) | (cnt << 24); dev->frame.cmd = MAPLE_COMMAND_CAMCONTROL; dev->frame.dst_port = dev->port; dev->frame.dst_unit = dev->unit; @@ -179,26 +208,84 @@ return MAPLE_EOK; } +static int dreameye_get_transfer_count(maple_device_t *dev, uint8 img) { + uint32 *send_buf; + + assert( dev != NULL); + + /* Lock the frame */ + if(maple_frame_lock(&dev->frame) < 0) + return MAPLE_EAGAIN; + + /* Reset the frame */ + maple_frame_init(&dev->frame); + send_buf = (uint32 *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CAMERA; + send_buf[1] = DREAMEYE_GETCOND_TRANSFER_COUNT | (img << 8); + dev->frame.cmd = MAPLE_COMMAND_GETCOND; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 2; + dev->frame.callback = dreameye_get_transfer_count_cb; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + /* Wait for the Dreameye to accept it */ + if(genwait_wait(&dev->frame, "dreameye_get_transfer_count", 500, + NULL) < 0) { + if(dev->frame.state != MAPLE_FRAME_VACANT) { + /* Something went wrong... */ + dev->frame.state = MAPLE_FRAME_VACANT; + dbglog(DBG_ERROR, "dreameye_get_transfer_count: timeout to unit " + "%c%c\n", dev->port + 'A', dev->unit + '0'); + return MAPLE_ETIMEOUT; + } + } + + return MAPLE_EOK; +} + int dreameye_get_image(maple_device_t *dev, uint8 image, uint8 **data, int *img_sz) { dreameye_state_t *de; + maple_device_t *dev2, *dev3, *dev4, *dev5; int err; - assert( dev != NULL); + assert( dev != NULL ); + assert( dev->unit == 1 ); + dev2 = maple_enum_dev(dev->port, 2); + dev3 = maple_enum_dev(dev->port, 3); + dev4 = maple_enum_dev(dev->port, 4); + dev5 = maple_enum_dev(dev->port, 5); + de = (dreameye_state_t *)dev->status; + first_state = de; de->img_transferring = 1; de->img_buf = NULL; de->img_size = 0; de->img_number = image; - de->img_counter = 0; + de->transfer_count = 0; - /* Set up the frame. */ - err = dreameye_send_get_image(dev, de, DREAMEYE_IMAGEREQ_START); + /* Figure out how many transfers we'll need. */ + err = dreameye_get_transfer_count(dev, image); if(err) - return err; + goto fail; + /* Allocate space for the largest possible image that could fit in that + number of transfers. */ + de->img_buf = (uint8 *)malloc(512 * de->transfer_count); + if(!de->img_buf) + goto fail; + + /* Send out the image requests to all sub devices. */ + dreameye_send_get_image(dev, de, DREAMEYE_IMAGEREQ_START, 0); + dreameye_send_get_image(dev2, de, DREAMEYE_IMAGEREQ_CONTINUE, 1); + dreameye_send_get_image(dev3, de, DREAMEYE_IMAGEREQ_CONTINUE, 2); + dreameye_send_get_image(dev4, de, DREAMEYE_IMAGEREQ_CONTINUE, 3); + dreameye_send_get_image(dev5, de, DREAMEYE_IMAGEREQ_CONTINUE, 4); + while(de->img_transferring == 1) { thd_pass(); } @@ -208,11 +295,12 @@ *img_sz = de->img_size; dbglog(DBG_DEBUG, "dreameye_get_image: Image of size %d received in " - "%d transfers\n", de->img_size, de->img_counter); + "%d transfers\n", de->img_size, de->transfer_count); + first_state = NULL; de->img_buf = NULL; de->img_size = 0; - de->img_counter = 0; + de->transfer_count = 0; return MAPLE_EOK; } @@ -221,10 +309,12 @@ free(de->img_buf); } +fail: + first_state = NULL; de->img_transferring = 0; de->img_buf = NULL; de->img_size = 0; - de->img_counter = 0; + de->transfer_count = 0; return MAPLE_EFAIL; } @@ -310,11 +400,11 @@ de = (dreameye_state_t *)dev->status; de->image_count = 0; de->image_count_valid = 0; + de->transfer_count = 0; de->img_transferring = 0; de->img_buf = NULL; de->img_size = 0; de->img_number = 0; - de->img_counter = 0; dev->status_valid = 1; return 0; Modified: kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h 2009-02-09 16:14:25 UTC (rev 627) +++ kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h 2009-02-15 21:12:43 UTC (rev 628) @@ -19,15 +19,16 @@ typedef struct dreameye_state { int image_count; int image_count_valid; + int transfer_count; int img_transferring; uint8 *img_buf; int img_size; uint8 img_number; - uint8 img_counter; } dreameye_state_t; /* Attributes that can be obtained with the Get Condition command. */ #define DREAMEYE_GETCOND_NUM_IMAGES 0x81 +#define DREAMEYE_GETCOND_TRANSFER_COUNT 0x83 /* Subcommands that are used with Camera Control command. */ #define DREAMEYE_SUBCOMMAND_IMAGEREQ 0x04 @@ -46,8 +47,8 @@ int dreameye_get_image_count(maple_device_t *dev, int block); /* Grab a specified image from the Dreameye. This command can take some time, - and (for the time being, anyway) will block. You can send this command to any - of the sub-devices. You are responsible for freeing the buffer after the + and (for the time being, anyway) will block. You must send this command to + the first sub-device. You are responsible for freeing the buffer after the command has completed if you recieve a MAPLE_EOK response. */ int dreameye_get_image(maple_device_t *dev, uint8 image, uint8 **data, int *img_sz); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-09 16:14:29
|
Revision: 627 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=627&view=rev Author: ljsebald Date: 2009-02-09 16:14:25 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Committing most of patch #2581322 from the tracker -- A bit of a cleanup of the maple code (mostly dealing with attaching and detaching of devices). Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/maple/controller.c kos/kernel/arch/dreamcast/hardware/maple/dreameye.c kos/kernel/arch/dreamcast/hardware/maple/keyboard.c kos/kernel/arch/dreamcast/hardware/maple/maple_driver.c kos/kernel/arch/dreamcast/hardware/maple/maple_utils.c kos/kernel/arch/dreamcast/hardware/maple/mouse.c kos/kernel/arch/dreamcast/hardware/maple/purupuru.c kos/kernel/arch/dreamcast/hardware/maple/sip.c kos/kernel/arch/dreamcast/hardware/maple/vmu.c kos/kernel/arch/dreamcast/include/dc/maple.h Modified: kos/kernel/arch/dreamcast/hardware/maple/controller.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/controller.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/controller.c 2009-02-09 16:14:25 UTC (rev 627) @@ -94,24 +94,13 @@ maple_driver_foreach(drv, cont_poll); } -static int cont_attach(maple_driver_t *drv, maple_device_t *dev) { - memset(dev->status, 0, sizeof(dev->status)); - dev->status_valid = 0; - return 0; -} - -static void cont_detach(maple_driver_t *drv, maple_device_t *dev) { - memset(dev->status, 0, sizeof(dev->status)); - dev->status_valid = 0; -} - /* Device Driver Struct */ static maple_driver_t controller_drv = { functions: MAPLE_FUNC_CONTROLLER, name: "Controller Driver", periodic: cont_periodic, - attach: cont_attach, - detach: cont_detach + attach: NULL, + detach: NULL }; /* Add the controller to the driver chain */ Modified: kos/kernel/arch/dreamcast/hardware/maple/dreameye.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-09 16:14:25 UTC (rev 627) @@ -320,16 +320,13 @@ return 0; } -static void dreameye_detach(maple_driver_t *drv, maple_device_t *dev) { -} - /* Device Driver Struct */ static maple_driver_t dreameye_drv = { functions: MAPLE_FUNC_CAMERA, name: "Dreameye (Camera)", periodic: dreameye_periodic, attach: dreameye_attach, - detach: dreameye_detach + detach: NULL }; /* Add the Dreameye to the driver chain */ Modified: kos/kernel/arch/dreamcast/hardware/maple/keyboard.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/keyboard.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/keyboard.c 2009-02-09 16:14:25 UTC (rev 627) @@ -190,24 +190,13 @@ maple_driver_foreach(drv, kbd_poll_intern); } -static int kbd_attach(maple_driver_t *drv, maple_device_t *dev) { - memset(dev->status, 0, sizeof(dev->status)); - dev->status_valid = 0; - return 0; -} - -static void kbd_detach(maple_driver_t *drv, maple_device_t *dev) { - memset(dev->status, 0, sizeof(dev->status)); - dev->status_valid = 0; -} - /* Device driver struct */ static maple_driver_t kbd_drv = { functions: MAPLE_FUNC_KEYBOARD, name: "Keyboard Driver", periodic: kbd_periodic, - attach: kbd_attach, - detach: kbd_detach + attach: NULL, + detach: NULL }; /* Add the keyboard to the driver chain */ Modified: kos/kernel/arch/dreamcast/hardware/maple/maple_driver.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/maple_driver.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/maple_driver.c 2009-02-09 16:14:25 UTC (rev 627) @@ -38,14 +38,15 @@ memcpy(&dev->info, devinfo, sizeof(maple_devinfo_t)); dev->info.product_name[29] = 0; dev->info.product_license[59] = 0; + memset(dev->status, 0, sizeof(dev->status)); dev->drv = NULL; /* Go through the list and look for a matching driver */ LIST_FOREACH(i, &maple_state.driver_list, drv_list) { /* For now we just pick the first matching driver */ if (i->functions & devinfo->functions) { - /* Driver matches, try an attach */ - if (i->attach(i, dev) >= 0) { + /* Driver matches, try an attach if we need to */ + if (!(i->attach) || (i->attach(i, dev) >= 0)) { /* Success: make it permanent */ attached = 1; break; @@ -75,6 +76,7 @@ if (dev->drv && dev->drv->detach) dev->drv->detach(dev->drv, dev); dev->valid = 0; + dev->status_valid = 0; return 0; } Modified: kos/kernel/arch/dreamcast/hardware/maple/maple_utils.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/maple_utils.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/maple_utils.c 2009-02-09 16:14:25 UTC (rev 627) @@ -94,7 +94,7 @@ /* Print the capabilities of a given driver to dbglog; NOT THREAD SAFE */ static char caps_buffer[1024]; const char * maple_pcaps(uint32 functions) { - int i, o; + unsigned int i, o; for (o=0, i=0; i<32; i++) { if (functions & (0x80000000 >> i)) { Modified: kos/kernel/arch/dreamcast/hardware/maple/mouse.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/mouse.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/mouse.c 2009-02-09 16:14:25 UTC (rev 627) @@ -66,23 +66,13 @@ maple_driver_foreach(drv, mouse_poll); } -static int mouse_attach(maple_driver_t *drv, maple_device_t *dev) { - memset(dev->status, 0, sizeof(dev->status)); - dev->status_valid = 0; - return 0; -} - -static void mouse_detach(maple_driver_t *drv, maple_device_t *dev) { - dev->status_valid = 0; -} - /* Device Driver Struct */ static maple_driver_t mouse_drv = { functions: MAPLE_FUNC_MOUSE, name: "Mouse Driver", periodic: mouse_periodic, - attach: mouse_attach, - detach: mouse_detach + attach: NULL, + detach: NULL }; /* Add the mouse to the driver chain */ Modified: kos/kernel/arch/dreamcast/hardware/maple/purupuru.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/purupuru.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/purupuru.c 2009-02-09 16:14:25 UTC (rev 627) @@ -108,16 +108,13 @@ return 0; } -static void purupuru_detach(maple_driver_t *drv, maple_device_t *dev) { -} - /* Device Driver Struct */ static maple_driver_t purupuru_drv = { functions: MAPLE_FUNC_PURUPURU, name: "PuruPuru (Vibration) Pack", periodic: purupuru_periodic, attach: purupuru_attach, - detach: purupuru_detach + detach: NULL }; /* Add the mouse to the driver chain */ Modified: kos/kernel/arch/dreamcast/hardware/maple/sip.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/sip.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/sip.c 2009-02-09 16:14:25 UTC (rev 627) @@ -357,19 +357,17 @@ /* Allocate the sample buffer for 10 seconds worth of samples (11.025kHz, 16-bit signed samples). */ sip = (sip_state_t *)dev->status; - sip->is_sampling = 0; - sip->amp_gain = SIP_DEFAULT_GAIN; - sip->buf_pos = 0; sip->samples_buf = (uint8 *)malloc(11025 * 2 * 10); - if(sip->samples_buf == NULL) { - dev->status_valid = 0; - sip->buf_len = 0; + if(sip->samples_buf == NULL) { return -1; } - else { - dev->status_valid = 1; + else { + sip->is_sampling = 0; + sip->amp_gain = SIP_DEFAULT_GAIN; + sip->buf_pos = 0; sip->buf_len = 11025 * 2 * 10; + dev->status_valid = 1; return 0; } } Modified: kos/kernel/arch/dreamcast/hardware/maple/vmu.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/vmu.c 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/hardware/maple/vmu.c 2009-02-09 16:14:25 UTC (rev 627) @@ -26,16 +26,13 @@ return 0; } -static void vmu_detach(maple_driver_t *drv, maple_device_t *dev) { -} - /* Device Driver Struct */ static maple_driver_t vmu_drv = { functions: MAPLE_FUNC_MEMCARD | MAPLE_FUNC_LCD | MAPLE_FUNC_CLOCK, name: "VMU Driver", periodic: NULL, attach: vmu_attach, - detach: vmu_detach + detach: NULL }; /* Add the VMU to the driver chain */ @@ -319,8 +316,8 @@ return rv; } -// Sometimes a flaky or stubborn card can be recovered by trying a couple -// of times... +/* Sometimes a flaky or stubborn card can be recovered by trying a couple + of times... */ int vmu_block_write(maple_device_t * dev, uint16 blocknum, uint8 *buffer) { int i, rv; for (i=0; i<4; i++) { @@ -329,11 +326,12 @@ if (rv == MAPLE_EOK) return rv; - // It failed -- wait a bit and try again. + /* It failed -- wait a bit and try again. */ thd_sleep(100); } - // Well, looks like it's really toasty... return the most recent error. + /* Well, looks like it's really toasty... return the most recent + error. */ return rv; } Modified: kos/kernel/arch/dreamcast/include/dc/maple.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-07 23:31:22 UTC (rev 626) +++ kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-09 16:14:25 UTC (rev 627) @@ -64,8 +64,8 @@ #define MAPLE_COMMAND_BWRITE 12 #define MAPLE_COMMAND_BSYNC 13 #define MAPLE_COMMAND_SETCOND 14 -#define MAPLE_COMMAND_MICCONTROL 15 -#define MAPLE_COMMAND_CAMCONTROL 17 +#define MAPLE_COMMAND_MICCONTROL 15 +#define MAPLE_COMMAND_CAMCONTROL 17 /* Function codes; most sources claim that these numbers are little endian, and for all I know, they might be; but since it's a bitmask This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-07 23:31:24
|
Revision: 626 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=626&view=rev Author: ljsebald Date: 2009-02-07 23:31:22 +0000 (Sat, 07 Feb 2009) Log Message: ----------- Adding in a new Dreameye driver that can grab saved images off of the Dreameye. Modified Paths: -------------- kos/doc/CHANGELOG kos/examples/dreamcast/Makefile kos/kernel/arch/dreamcast/hardware/maple/dreameye.c kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h kos/kernel/arch/dreamcast/include/dc/maple.h Added Paths: ----------- kos/examples/dreamcast/dreameye/ kos/examples/dreamcast/dreameye/Makefile kos/examples/dreamcast/dreameye/basic/ kos/examples/dreamcast/dreameye/basic/Makefile kos/examples/dreamcast/dreameye/basic/dreameye.c Modified: kos/doc/CHANGELOG =================================================================== --- kos/doc/CHANGELOG 2009-02-07 22:53:58 UTC (rev 625) +++ kos/doc/CHANGELOG 2009-02-07 23:31:22 UTC (rev 626) @@ -177,6 +177,8 @@ - DC Added reading of the ISP settings from PlanetWeb to the flashrom code [LS] - DC Fixed various pieces of code that rely on flashrom_ispcfg_t [LS] - *** Added an implementation of DHCP to the network stack [LS] +- DC Added Dreameye driver that is capable of fetching stored images from the + device. [LS] KallistiOS version 1.2.0 ----------------------------------------------- - DC Fix to use DCARM7_CFLAGS when compiling ARM driver [Christian Groessler == CG] Modified: kos/examples/dreamcast/Makefile =================================================================== --- kos/examples/dreamcast/Makefile 2009-02-07 22:53:58 UTC (rev 625) +++ kos/examples/dreamcast/Makefile 2009-02-07 23:31:22 UTC (rev 626) @@ -4,7 +4,7 @@ # Copyright (C)2003 Dan Potter # -DIRS = 2ndmix basic libdream kgl hello sound png network vmu conio pvr video lua parallax modem +DIRS = 2ndmix basic libdream kgl hello sound png network vmu conio pvr video lua parallax modem dreameye ifdef KOS_CCPLUS DIRS += cpp tsunami endif Added: kos/examples/dreamcast/dreameye/Makefile =================================================================== --- kos/examples/dreamcast/dreameye/Makefile (rev 0) +++ kos/examples/dreamcast/dreameye/Makefile 2009-02-07 23:31:22 UTC (rev 626) @@ -0,0 +1,15 @@ +# KallistiOS ##version## +# +# examples/dreamcast/dreameye/Makefile +# Copyright (C) 2009 Lawrence Sebald +# + +all: + $(KOS_MAKE) -C basic + +clean: + $(KOS_MAKE) -C basic clean + +dist: + $(KOS_MAKE) -C basic dist + Added: kos/examples/dreamcast/dreameye/basic/Makefile =================================================================== --- kos/examples/dreamcast/dreameye/basic/Makefile (rev 0) +++ kos/examples/dreamcast/dreameye/basic/Makefile 2009-02-07 23:31:22 UTC (rev 626) @@ -0,0 +1,29 @@ +# KallistiOS ##version## +# +# examples/dreamcast/dreameye/basic/Makefile +# Copyright (C) 2009 Lawrence Sebald +# + +all: rm-elf dreameye_test.elf + +include $(KOS_BASE)/Makefile.rules + +OBJS = dreameye.o + +clean: rm-elf + -rm -f $(OBJS) + +rm-elf: + -rm -f dreameye_test.elf + +dreameye_test.elf: $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o dreameye_test.elf $(KOS_START) \ + $(OBJS) $(DATAOBJS) $(OBJEXTRA) $(KOS_LIBS) + + +run: dreameye_test.elf + $(KOS_LOADER) dreameye_test.elf + +dist: + rm -f $(OBJS) + $(KOS_STRIP) dreameye_test.elf Added: kos/examples/dreamcast/dreameye/basic/dreameye.c =================================================================== --- kos/examples/dreamcast/dreameye/basic/dreameye.c (rev 0) +++ kos/examples/dreamcast/dreameye/basic/dreameye.c 2009-02-07 23:31:22 UTC (rev 626) @@ -0,0 +1,61 @@ +/* KallistiOS ##version## + + dreameye.c + Copyright (C) 2009 Lawrence Sebald +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include <dc/maple.h> +#include <dc/maple/dreameye.h> + +int main(int argc, char *argv[]) { + maple_device_t *dreameye; + dreameye_state_t *state; + uint8 *buf; + int size, err; + FILE *fp; + + printf("KallistiOS Dreameye Test program\n"); + printf("Attempting to find a connected Dreameye device...\n"); + + dreameye = maple_enum_type(0, MAPLE_FUNC_CAMERA); + + if(!dreameye) { + printf("Couldn't find any attached devices, bailing out.\n"); + return 0; + } + + state = (dreameye_state_t *)maple_dev_status(dreameye); + + printf("Attempting to grab the number of saved images...\n"); + dreameye_get_image_count(dreameye, 1); + + printf("Image Count is %s -- (%d)\n", + state->image_count_valid ? "valid" : "invalid", state->image_count); + + printf("Attempting to grab the first image.\n"); + err = dreameye_get_image(dreameye, 2, &buf, &size); + + if(err != MAPLE_EOK) { + printf("Error was: %d\n", err); + return 0; + } + + printf("Image received successfully, size %d bytes\n", size); + + fp = fopen("/pc/image.jpg", "wb"); + if(!fp) { + printf("Could not open /pc/image.jpg for writing\n"); + free(buf); + return 0; + } + + fwrite(buf, size, 1, fp); + fclose(fp); + free(buf); + + printf("That's all for now.\n"); + return 0; +} Modified: kos/kernel/arch/dreamcast/hardware/maple/dreameye.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-07 22:53:58 UTC (rev 625) +++ kos/kernel/arch/dreamcast/hardware/maple/dreameye.c 2009-02-07 23:31:22 UTC (rev 626) @@ -1,18 +1,323 @@ /* KallistiOS ##version## dreameye.c - Copyright (C) 2005 Lawrence Sebald + Copyright (C) 2005, 2009 Lawrence Sebald */ +#include <assert.h> +#include <string.h> +#include <stdlib.h> + +#include <kos/dbglog.h> +#include <kos/genwait.h> #include <dc/maple.h> #include <dc/maple/dreameye.h> +static int dreameye_send_get_image(maple_device_t *dev, + dreameye_state_t *state, uint8 req); + +static void dreameye_get_image_count_cb(maple_frame_t *frame) { + dreameye_state_t *de; + maple_response_t *resp; + uint32 *respbuf32; + uint8 *respbuf8; + + /* Unlock the frame */ + maple_frame_unlock(frame); + + /* Make sure we got a valid response */ + resp = (maple_response_t *)frame->recv_buf; + if(resp->response != MAPLE_RESPONSE_DATATRF) + return; + + respbuf32 = (uint32 *)resp->data; + respbuf8 = (uint8 *)resp->data; + if(respbuf32[0] != MAPLE_FUNC_CAMERA) + return; + + /* Update the status that was requested. */ + if(frame->dev) { + assert( (resp->data_len) == 3 ); + assert( respbuf8[4] == 0xD0 ); + assert( respbuf8[5] == 0x00 ); + assert( respbuf8[8] == DREAMEYE_GETCOND_NUM_IMAGES ); + assert( respbuf8[9] == 0x04 ); + + /* Update the data in the status. */ + de = (dreameye_state_t *)frame->dev->status; + de->image_count = (respbuf8[10] << 8) | respbuf8[11]; + de->image_count_valid = 1; + frame->dev->status_valid = 1; + } + + /* Wake up! */ + genwait_wake_all(frame); +} + +int dreameye_get_image_count(maple_device_t *dev, int block) { + dreameye_state_t *de; + uint32 *send_buf; + + assert( dev != NULL); + + de = (dreameye_state_t *)dev->status; + de->image_count_valid = 0; + + /* Lock the frame */ + if(maple_frame_lock(&dev->frame) < 0) + return MAPLE_EAGAIN; + + /* Reset the frame */ + maple_frame_init(&dev->frame); + send_buf = (uint32 *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CAMERA; + send_buf[1] = DREAMEYE_GETCOND_NUM_IMAGES | (0x04 << 8); + dev->frame.cmd = MAPLE_COMMAND_GETCOND; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 2; + dev->frame.callback = dreameye_get_image_count_cb; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + if(block) { + /* Wait for the Dreameye to accept it */ + if(genwait_wait(&dev->frame, "dreameye_get_image_count", 500, + NULL) < 0) { + if(dev->frame.state != MAPLE_FRAME_VACANT) { + /* Something went wrong... */ + dev->frame.state = MAPLE_FRAME_VACANT; + dbglog(DBG_ERROR, "dreameye_get_image_count: timeout to unit " + "%c%c\n", dev->port + 'A', dev->unit + '0'); + return MAPLE_ETIMEOUT; + } + } + } + + return MAPLE_EOK; +} + +static void dreameye_get_image_cb(maple_frame_t *frame) { + maple_device_t *dev; + dreameye_state_t *de; + maple_response_t *resp; + uint32 *respbuf32; + uint8 *respbuf8; + int len; + uint8 *tmp; + + /* Unlock the frame */ + maple_frame_unlock(frame); + + if(frame->dev == NULL) + return; + + dev = frame->dev; + de = (dreameye_state_t *)frame->dev->status; + + /* Make sure we got a valid response */ + resp = (maple_response_t *)frame->recv_buf; + if(resp->response != MAPLE_RESPONSE_DATATRF) { + de->img_transferring = -1; + return; + } + + respbuf32 = (uint32 *)resp->data; + respbuf8 = (uint8 *)resp->data; + if(respbuf32[0] != MAPLE_FUNC_CAMERA) { + de->img_transferring = -1; + return; + } + + len = (resp->data_len - 3) * 4; + + /* Allocate space for the data. */ + tmp = (uint8 *)realloc(de->img_buf, de->img_size + len); + + if(tmp == NULL) { + de->img_transferring = -1; + return; + } + + /* Copy the data. */ + memcpy(tmp + de->img_size, respbuf8 + 12, len); + de->img_buf = tmp; + de->img_size += len; + de->img_counter = respbuf8[5] + 1; + + /* Check if we're done. */ + if(respbuf8[4] & 0x40) { + de->img_transferring = 0; + return; + } + + dreameye_send_get_image(dev, de, DREAMEYE_IMAGEREQ_CONTINUE); +} + +static int dreameye_send_get_image(maple_device_t *dev, + dreameye_state_t *state, uint8 req) { + uint32 *send_buf; + + /* Lock the frame */ + if(maple_frame_lock(&dev->frame) < 0) + return MAPLE_EAGAIN; + + /* Reset the frame */ + maple_frame_init(&dev->frame); + send_buf = (uint32 *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CAMERA; + send_buf[1] = DREAMEYE_SUBCOMMAND_IMAGEREQ | (state->img_number << 8) | + (req << 16) | (state->img_counter << 24); + dev->frame.cmd = MAPLE_COMMAND_CAMCONTROL; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 2; + dev->frame.callback = dreameye_get_image_cb; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + return MAPLE_EOK; +} + +int dreameye_get_image(maple_device_t *dev, uint8 image, uint8 **data, + int *img_sz) { + dreameye_state_t *de; + int err; + + assert( dev != NULL); + + de = (dreameye_state_t *)dev->status; + + de->img_transferring = 1; + de->img_buf = NULL; + de->img_size = 0; + de->img_number = image; + de->img_counter = 0; + + /* Set up the frame. */ + err = dreameye_send_get_image(dev, de, DREAMEYE_IMAGEREQ_START); + if(err) + return err; + + while(de->img_transferring == 1) { + thd_pass(); + } + + if(de->img_transferring == 0) { + *data = de->img_buf; + *img_sz = de->img_size; + + dbglog(DBG_DEBUG, "dreameye_get_image: Image of size %d received in " + "%d transfers\n", de->img_size, de->img_counter); + + de->img_buf = NULL; + de->img_size = 0; + de->img_counter = 0; + return MAPLE_EOK; + } + + /* If we get here, something went wrong. */ + if(de->img_buf != NULL) { + free(de->img_buf); + } + + de->img_transferring = 0; + de->img_buf = NULL; + de->img_size = 0; + de->img_counter = 0; + + return MAPLE_EFAIL; +} + +static void dreameye_erase_cb(maple_frame_t *frame) { + maple_response_t *resp; + uint8 *respbuf; + + /* Unlock the frame */ + maple_frame_unlock(frame); + + /* Make sure we got a valid response */ + resp = (maple_response_t *)frame->recv_buf; + respbuf = (uint8 *)resp->data; + + if(resp->response == MAPLE_COMMAND_CAMCONTROL && + respbuf[4] == DREAMEYE_SUBCOMMAND_ERROR) { + dbglog(DBG_ERROR, "dreameye_erase_image: Dreameye returned error code " + "0x%02X%02X%02X\n", respbuf[5], respbuf[6], respbuf[7]); + } + else if(resp->response != MAPLE_RESPONSE_OK) + return; + + /* Wake up! */ + genwait_wake_all(frame); +} + +int dreameye_erase_image(maple_device_t *dev, uint8 image, int block) { + uint32 *send_buf; + + assert( dev != NULL ); + + if(image < 0x02 || (image > 0x21 && image != 0xFF)) + return MAPLE_EINVALID; + + /* Lock the frame */ + if(maple_frame_lock(&dev->frame) < 0) + return MAPLE_EAGAIN; + + /* Reset the frame */ + maple_frame_init(&dev->frame); + send_buf = (uint32 *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CAMERA; + send_buf[1] = DREAMEYE_SUBCOMMAND_ERASE | (0x80 << 8) | (image << 16); + dev->frame.cmd = MAPLE_COMMAND_CAMCONTROL; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 2; + dev->frame.callback = dreameye_erase_cb; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + if(block) { + /* Wait for the Dreameye to accept it */ + if(genwait_wait(&dev->frame, "dreameye_erase_image", 500, NULL) < 0) { + if(dev->frame.state != MAPLE_FRAME_VACANT) { + /* Something went wrong.... */ + dev->frame.state = MAPLE_FRAME_VACANT; + dbglog(DBG_ERROR, "dreameye_erase_image: timeout to unit " + "%c%c\n", dev->port + 'A', dev->unit + '0'); + return MAPLE_ETIMEOUT; + } + } + } + + return MAPLE_EOK; +} + +static int dreameye_poll(maple_device_t *dev) { + /* For right now, we don't have anything particularly pressing to do here, + so punt. */ + dev->status_valid = 1; + return 0; +} + static void dreameye_periodic(maple_driver_t *drv) { + maple_driver_foreach(drv, dreameye_poll); } static int dreameye_attach(maple_driver_t *drv, maple_device_t *dev) { - dev->status_valid = 1; - return 0; + dreameye_state_t *de; + + de = (dreameye_state_t *)dev->status; + de->image_count = 0; + de->image_count_valid = 0; + de->img_transferring = 0; + de->img_buf = NULL; + de->img_size = 0; + de->img_number = 0; + de->img_counter = 0; + + dev->status_valid = 1; + return 0; } static void dreameye_detach(maple_driver_t *drv, maple_device_t *dev) { @@ -20,18 +325,18 @@ /* Device Driver Struct */ static maple_driver_t dreameye_drv = { - functions: MAPLE_FUNC_CAMERA, - name: "Dreameye (Camera)", - periodic: dreameye_periodic, - attach: dreameye_attach, - detach: dreameye_detach + functions: MAPLE_FUNC_CAMERA, + name: "Dreameye (Camera)", + periodic: dreameye_periodic, + attach: dreameye_attach, + detach: dreameye_detach }; -/* Add the DreamEye to the driver chain */ +/* Add the Dreameye to the driver chain */ int dreameye_init() { - return maple_driver_reg(&dreameye_drv); + return maple_driver_reg(&dreameye_drv); } void dreameye_shutdown() { - maple_driver_unreg(&dreameye_drv); + maple_driver_unreg(&dreameye_drv); } Modified: kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h 2009-02-07 22:53:58 UTC (rev 625) +++ kos/kernel/arch/dreamcast/include/dc/maple/dreameye.h 2009-02-07 23:31:22 UTC (rev 626) @@ -1,7 +1,7 @@ /* KallistiOS ##version## dc/maple/dreameye.h - Copyright (C) 2005 Lawrence Sebald + Copyright (C) 2005, 2009 Lawrence Sebald */ @@ -13,9 +13,52 @@ #include <arch/types.h> -/* There's nothing much here to see right now, just stuff - to make the detection work. */ +/* Dreameye Status structure. Everything in here should be considered to be + read-only from user programs. Note that most of this is used for keeping + track of what's going on during an image transfer. */ +typedef struct dreameye_state { + int image_count; + int image_count_valid; + int img_transferring; + uint8 *img_buf; + int img_size; + uint8 img_number; + uint8 img_counter; +} dreameye_state_t; +/* Attributes that can be obtained with the Get Condition command. */ +#define DREAMEYE_GETCOND_NUM_IMAGES 0x81 + +/* Subcommands that are used with Camera Control command. */ +#define DREAMEYE_SUBCOMMAND_IMAGEREQ 0x04 +#define DREAMEYE_SUBCOMMAND_ERASE 0x05 +#define DREAMEYE_SUBCOMMAND_ERROR 0xFF + +/* Used with the image request subcommand. */ +#define DREAMEYE_IMAGEREQ_CONTINUE 0x00 +#define DREAMEYE_IMAGEREQ_START 0x40 + +/* Grab the current number of saved images on the Dreameye. This command can be + sent to any of the sub-devices. Set block to 1 in order to wait for a + response from the Dreameye. When a response arrives, the state image_count + will be set and image_count_valid will be set to 1. The return value from + this function IS NOT the number of images. Returns MAPLE_EOK on success. */ +int dreameye_get_image_count(maple_device_t *dev, int block); + +/* Grab a specified image from the Dreameye. This command can take some time, + and (for the time being, anyway) will block. You can send this command to any + of the sub-devices. You are responsible for freeing the buffer after the + command has completed if you recieve a MAPLE_EOK response. */ +int dreameye_get_image(maple_device_t *dev, uint8 image, uint8 **data, + int *img_sz); + +/* Erase an image from the Dreameye. This command can be sent to any of the + sub-devices. Set block to 1 in order to wait for a response from the + Dreameye. Pass an image of 0xFF to erase all images from the Dreameye. + Returns MAPLE_EOK on success, MAPLE_EINVALID if an invalid image number is + passed in. */ +int dreameye_erase_image(maple_device_t *dev, uint8 image, int block); + /* Init / Shutdown */ int dreameye_init(); void dreameye_shutdown(); Modified: kos/kernel/arch/dreamcast/include/dc/maple.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-07 22:53:58 UTC (rev 625) +++ kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-07 23:31:22 UTC (rev 626) @@ -65,6 +65,7 @@ #define MAPLE_COMMAND_BSYNC 13 #define MAPLE_COMMAND_SETCOND 14 #define MAPLE_COMMAND_MICCONTROL 15 +#define MAPLE_COMMAND_CAMCONTROL 17 /* Function codes; most sources claim that these numbers are little endian, and for all I know, they might be; but since it's a bitmask This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-07 22:54:00
|
Revision: 625 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=625&view=rev Author: ljsebald Date: 2009-02-07 22:53:58 +0000 (Sat, 07 Feb 2009) Log Message: ----------- Prevent an infinite loop if maple_dev_status is called on a microphone before it has started sampling at all. Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c kos/kernel/arch/dreamcast/hardware/maple/sip.c Modified: kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c 2009-02-06 02:25:59 UTC (rev 624) +++ kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c 2009-02-07 22:53:58 UTC (rev 625) @@ -7,7 +7,6 @@ #include <dc/maple.h> #include <kos/thread.h> -#include <kos/dbglog.h> /* Return the number of connected devices */ int maple_enum_count() { Modified: kos/kernel/arch/dreamcast/hardware/maple/sip.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/sip.c 2009-02-06 02:25:59 UTC (rev 624) +++ kos/kernel/arch/dreamcast/hardware/maple/sip.c 2009-02-07 22:53:58 UTC (rev 625) @@ -323,6 +323,7 @@ /* Test to make sure that the particular mic is enabled */ if(!sip->is_sampling) { + dev->status_valid = 1; return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-06 02:26:02
|
Revision: 624 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=624&view=rev Author: ljsebald Date: 2009-02-06 02:25:59 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Fix maple_enum_type_ex so that it actually works as advertised. Modified Paths: -------------- kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c Modified: kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c 2009-02-04 21:46:56 UTC (rev 623) +++ kos/kernel/arch/dreamcast/hardware/maple/maple_enum.c 2009-02-06 02:25:59 UTC (rev 624) @@ -7,6 +7,7 @@ #include <dc/maple.h> #include <kos/thread.h> +#include <kos/dbglog.h> /* Return the number of connected devices */ int maple_enum_count() { @@ -81,6 +82,8 @@ /* Check if the function data for the function type checks out with what it should be. */ + cap = ((cap >> 24) & 0xFF) | ((cap >> 8) & 0xFF00) | + ((cap & 0xFF00) << 8) | ((cap & 0xFF) << 24); if((dev->info.function_data[d] & cap) == cap) { if(!n) return dev; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-04 22:22:10
|
Revision: 623 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=623&view=rev Author: ljsebald Date: 2009-02-04 21:46:56 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Clean up a whole bunch of warnings. Modified Paths: -------------- kos/include/kos/thread.h kos/kernel/arch/dreamcast/fs/fs_dcload.c kos/kernel/arch/dreamcast/hardware/cdrom.c kos/kernel/arch/dreamcast/include/dc/fs_dcload.h kos/kernel/arch/dreamcast/kernel/entry.s kos/kernel/arch/dreamcast/kernel/irq.c kos/kernel/arch/dreamcast/sound/snd_stream.c kos/kernel/exports/nmmgr.c kos/kernel/fs/fs.c kos/kernel/fs/fs_pty.c kos/kernel/fs/fs_romdisk.c kos/kernel/libc/koslib/realpath.c kos/utils/gba-crcfix/Makefile kos/utils/genromfs/Makefile kos/utils/vqenc/Makefile kos/utils/vqenc/readpng.c kos/utils/vqenc/readpng.h kos/utils/wav2adpcm/Makefile kos/utils/wav2adpcm/wav2adpcm.c Modified: kos/include/kos/thread.h =================================================================== --- kos/include/kos/thread.h 2009-02-03 18:32:27 UTC (rev 622) +++ kos/include/kos/thread.h 2009-02-04 21:46:56 UTC (rev 623) @@ -202,7 +202,13 @@ /* Wait for a thread to exit */ int thd_wait(kthread_t * thd); +/* Print a list of all threads using the given print function. */ +int thd_pslist(int (*pf)(const char *fmt, ...)); +/* Print a list of all queued threads using the given print function. */ +int thd_pslist_queue(int (*pf)(const char *fmt, ...)); + + /* Init */ int thd_init(int mode); Modified: kos/kernel/arch/dreamcast/fs/fs_dcload.c =================================================================== --- kos/kernel/arch/dreamcast/fs/fs_dcload.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/fs/fs_dcload.c 2009-02-04 21:46:56 UTC (rev 623) @@ -91,13 +91,13 @@ } static char *dcload_path = NULL; -uint32 dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { +void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { int hnd = 0; uint32 h; int dcload_mode = 0; if (lwip_dclsc && irq_inside_int()) - return 0; + return (void *)0; spinlock_lock(&mutex); @@ -136,10 +136,12 @@ h = hnd; spinlock_unlock(&mutex); - return h; + return (void *)h; } -void dcload_close(uint32 hnd) { +void dcload_close(void * h) { + uint32 hnd = (uint32)h; + if (lwip_dclsc && irq_inside_int()) return; @@ -156,8 +158,9 @@ spinlock_unlock(&mutex); } -ssize_t dcload_read(uint32 hnd, void *buf, size_t cnt) { +ssize_t dcload_read(void * h, void *buf, size_t cnt) { ssize_t ret = -1; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; @@ -173,8 +176,9 @@ return ret; } -ssize_t dcload_write(uint32 hnd, const void *buf, size_t cnt) { +ssize_t dcload_write(void * h, const void *buf, size_t cnt) { ssize_t ret = -1; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; @@ -190,8 +194,9 @@ return ret; } -off_t dcload_seek(uint32 hnd, off_t offset, int whence) { +off_t dcload_seek(void * h, off_t offset, int whence) { off_t ret = -1; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; @@ -207,8 +212,9 @@ return ret; } -off_t dcload_tell(uint32 hnd) { +off_t dcload_tell(void * h) { off_t ret = -1; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; @@ -224,9 +230,10 @@ return ret; } -size_t dcload_total(uint32 hnd) { +size_t dcload_total(void * h) { size_t ret = -1; size_t cur; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; @@ -246,11 +253,12 @@ /* Not thread-safe, but that's ok because neither is the FS */ static dirent_t dirent; -dirent_t *dcload_readdir(uint32 hnd) { +dirent_t *dcload_readdir(void * h) { dirent_t *rv = NULL; dcload_dirent_t *dcld; dcload_stat_t filestat; char *fn; + uint32 hnd = (uint32)h; if (lwip_dclsc && irq_inside_int()) return 0; Modified: kos/kernel/arch/dreamcast/hardware/cdrom.c =================================================================== --- kos/kernel/arch/dreamcast/hardware/cdrom.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/hardware/cdrom.c 2009-02-04 21:46:56 UTC (rev 623) @@ -59,11 +59,15 @@ /* Set disc access mode */ 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 */ static void gdc_reset() { MAKE_SYSCALL(/**/, 0, 0, 9); } /* Abort the current command */ static void gdc_abort_cmd(int cmd) { MAKE_SYSCALL(/**/,cmd, 0, 8); } +#endif /* The CD access mutex */ static mutex_t * mutex = NULL; Modified: kos/kernel/arch/dreamcast/include/dc/fs_dcload.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/fs_dcload.h 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/include/dc/fs_dcload.h 2009-02-04 21:46:56 UTC (rev 623) @@ -101,13 +101,13 @@ size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_t out_size); /* File functions */ -uint32 dcload_open(vfs_handler_t * vfs, const char *fn, int mode); -void dcload_close(uint32 hnd); -ssize_t dcload_read(uint32 hnd, void *buf, size_t cnt); -off_t dcload_seek(uint32 hnd, off_t offset, int whence); -off_t dcload_tell(uint32 hnd); -size_t dcload_total(uint32 hnd); -dirent_t* dcload_readdir(uint32 hnd); +void* dcload_open(vfs_handler_t * vfs, const char *fn, int mode); +void dcload_close(void * hnd); +ssize_t dcload_read(void * hnd, void *buf, size_t cnt); +off_t dcload_seek(void * hnd, off_t offset, int whence); +off_t dcload_tell(void * hnd); +size_t dcload_total(void * hnd); +dirent_t* dcload_readdir(void * hnd); int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2); int dcload_unlink(vfs_handler_t * vfs, const char *fn); Modified: kos/kernel/arch/dreamcast/kernel/entry.s =================================================================== --- kos/kernel/arch/dreamcast/kernel/entry.s 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/kernel/entry.s 2009-02-04 21:46:56 UTC (rev 623) @@ -272,9 +272,11 @@ mov.l tmh_shortcut_addr,r0 mov.l @r0,r0 cmp/pz r0 - bf/s _irq_save_regs + bt tmh_clear + bra _irq_save_regs mov #2,r4 +tmh_clear: ! Coast is clear -- setup the args and call the C function. Regs R0-R7 ! are volatile on SH-4 anyway, and R8-R14 will be saved if needed ! onto our temp stack. So all we need to worry about here, at least Modified: kos/kernel/arch/dreamcast/kernel/irq.c =================================================================== --- kos/kernel/arch/dreamcast/kernel/irq.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/kernel/irq.c 2009-02-04 21:46:56 UTC (rev 623) @@ -12,6 +12,7 @@ #include <arch/types.h> #include <arch/irq.h> #include <arch/timer.h> +#include <arch/stack.h> #include <kos/dbgio.h> #include <kos/thread.h> #include <kos/library.h> Modified: kos/kernel/arch/dreamcast/sound/snd_stream.c =================================================================== --- kos/kernel/arch/dreamcast/sound/snd_stream.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/arch/dreamcast/sound/snd_stream.c 2009-02-04 21:46:56 UTC (rev 623) @@ -11,6 +11,7 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <malloc.h> #include <sys/queue.h> #include <arch/timer.h> Modified: kos/kernel/exports/nmmgr.c =================================================================== --- kos/kernel/exports/nmmgr.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/exports/nmmgr.c 2009-02-04 21:46:56 UTC (rev 623) @@ -20,6 +20,7 @@ #include <string.h> #include <kos/nmmgr.h> #include <kos/mutex.h> +#include <kos/exports.h> /* Thread mutex for our name handler list */ static mutex_t * mutex; Modified: kos/kernel/fs/fs.c =================================================================== --- kos/kernel/fs/fs.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/fs/fs.c 2009-02-04 21:46:56 UTC (rev 623) @@ -37,6 +37,7 @@ #include <kos/thread.h> #include <kos/mutex.h> #include <kos/nmmgr.h> +#include <kos/dbgio.h> /* File handle structure; this is an entirely internal structure so it does not go in a header file. */ @@ -49,7 +50,10 @@ /* The global file descriptor table */ fs_hnd_t * fd_table[FD_SETSIZE] = { NULL }; +/* For some reason, Newlib doesn't seem to define this function in stdlib.h. */ +extern char *realpath(const char *, const char *); + /* Internal file commands for root dir reading */ static fs_hnd_t * fs_root_opendir() { fs_hnd_t *hnd; Modified: kos/kernel/fs/fs_pty.c =================================================================== --- kos/kernel/fs/fs_pty.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/fs/fs_pty.c 2009-02-04 21:46:56 UTC (rev 623) @@ -30,6 +30,7 @@ #include <sys/queue.h> #include <malloc.h> #include <string.h> +#include <stdlib.h> #include <stdio.h> #include <assert.h> #include <errno.h> @@ -553,8 +554,7 @@ } /* Get total size. For this we return the number of bytes available for reading. */ -static ssize_t pty_total(void * h) { - int avail; +static size_t pty_total(void * h) { pipefd_t * fdobj; ptyhalf_t * ph; Modified: kos/kernel/fs/fs_romdisk.c =================================================================== --- kos/kernel/fs/fs_romdisk.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/fs/fs_romdisk.c 2009-02-04 21:46:56 UTC (rev 623) @@ -431,7 +431,7 @@ if (c->own_buffer) dbglog(DBG_DEBUG, " (and also freeing its image buffer)\n"); - assert( &c->vfsh->nmmgr == c->vfsh ); + assert( (void *)&c->vfsh->nmmgr == (void *)c->vfsh ); if (c->own_buffer) free((void *)c->image); nmmgr_handler_remove(&c->vfsh->nmmgr); @@ -489,7 +489,7 @@ vfsh->privdata = (void *)mnt; mnt->vfsh = vfsh; - assert( &mnt->vfsh->nmmgr == mnt->vfsh ); + assert( (void *)&mnt->vfsh->nmmgr == (void *)mnt->vfsh ); /* Add it to our mount list */ mutex_lock(fh_mutex); @@ -525,7 +525,7 @@ dbglog(DBG_DEBUG, " (and also freeing its image buffer)\n"); /* Unmount it */ - assert( &n->vfsh->nmmgr == n->vfsh ); + assert( (void *)&n->vfsh->nmmgr == (void *)n->vfsh ); nmmgr_handler_remove(&n->vfsh->nmmgr); /* If we own the buffer, free it */ Modified: kos/kernel/libc/koslib/realpath.c =================================================================== --- kos/kernel/libc/koslib/realpath.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/kernel/libc/koslib/realpath.c 2009-02-04 21:46:56 UTC (rev 623) @@ -31,6 +31,7 @@ #include <sys/param.h> #include <sys/stat.h> #include <kos/limits.h> +#include <kos/fs.h> #include <errno.h> #include <stdlib.h> Modified: kos/utils/gba-crcfix/Makefile =================================================================== --- kos/utils/gba-crcfix/Makefile 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/gba-crcfix/Makefile 2009-02-04 21:46:56 UTC (rev 623) @@ -1,6 +1,6 @@ -CFLAGS = -O2 -g -Wall -DINLINE=inline #-g# -LDFLAGS = -s -g #-g +CFLAGS = -O2 -Wall -DINLINE=inline #-g# +#LDFLAGS = -s -g TARGET=gba-crcfix OBJS=gba-crcfix.o Modified: kos/utils/genromfs/Makefile =================================================================== --- kos/utils/genromfs/Makefile 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/genromfs/Makefile 2009-02-04 21:46:56 UTC (rev 623) @@ -2,7 +2,7 @@ # Makefile for the genromfs program. CFLAGS = -O2 -Wall #-g# -LDFLAGS = -s#-g +#LDFLAGS = -s -g all: genromfs Modified: kos/utils/vqenc/Makefile =================================================================== --- kos/utils/vqenc/Makefile 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/vqenc/Makefile 2009-02-04 21:46:56 UTC (rev 623) @@ -7,7 +7,7 @@ # Use for other systems CFLAGS = -O2 -Wall -DINLINE=inline #-g# -LDFLAGS = -s -lpng -ljpeg -lz #-g +LDFLAGS = -lpng -ljpeg -lz #-s -g all: vqenc Modified: kos/utils/vqenc/readpng.c =================================================================== --- kos/utils/vqenc/readpng.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/vqenc/readpng.c 2009-02-04 21:46:56 UTC (rev 623) @@ -60,7 +60,7 @@ return 0; } -uint8 *readpng_get_image(uint32 *pChannels, uint32 *pRowbytes, uint32 *pWidth, uint32 *pHeight) +uint8 *readpng_get_image(uint32 *pChannels, uint32 *pRowbytes, int *pWidth, int *pHeight) { png_uint_32 width, height; int bit_depth, color_type; @@ -76,8 +76,8 @@ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); - *pWidth = width; - *pHeight = height; + *pWidth = (int)width; + *pHeight = (int)height; /* expand palette images to RGB, low-bit-depth grayscale images to 8 bits, * transparency chunks to full alpha channel; strip 16-bit-per-sample Modified: kos/utils/vqenc/readpng.h =================================================================== --- kos/utils/vqenc/readpng.h 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/vqenc/readpng.h 2009-02-04 21:46:56 UTC (rev 623) @@ -33,6 +33,6 @@ * The caller is responsible for freeing the memory */ uint8 *readpng_get_image(uint32 *pNumChannels, - uint32 *pRowBytes, uint32 *pWidth, uint32 *pHeight); + uint32 *pRowBytes, int *pWidth, int *pHeight); void readpng_cleanup(void); Modified: kos/utils/wav2adpcm/Makefile =================================================================== --- kos/utils/wav2adpcm/Makefile 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/wav2adpcm/Makefile 2009-02-04 21:46:56 UTC (rev 623) @@ -1,8 +1,8 @@ # Makefile for the wav2adpcm program. -CFLAGS = -O2 -Wall -g -LDFLAGS = -g +CFLAGS = -O2 -Wall #-g# +#LDFLAGS = -g all: wav2adpcm Modified: kos/utils/wav2adpcm/wav2adpcm.c =================================================================== --- kos/utils/wav2adpcm/wav2adpcm.c 2009-02-03 18:32:27 UTC (rev 622) +++ kos/utils/wav2adpcm/wav2adpcm.c 2009-02-04 21:46:56 UTC (rev 623) @@ -17,6 +17,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> static int diff_lookup[16] = { 1,3,5,7,9,11,13,15, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 18:32:31
|
Revision: 622 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=622&view=rev Author: ljsebald Date: 2009-02-03 18:32:27 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Mark the old Maple API compatibility functions as deprecated. Modified Paths: -------------- kos/kernel/arch/dreamcast/include/dc/maple/controller.h kos/kernel/arch/dreamcast/include/dc/maple/mouse.h kos/kernel/arch/dreamcast/include/dc/maple.h Modified: kos/kernel/arch/dreamcast/include/dc/maple/controller.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple/controller.h 2009-02-03 18:28:53 UTC (rev 621) +++ kos/kernel/arch/dreamcast/include/dc/maple/controller.h 2009-02-03 18:32:27 UTC (rev 622) @@ -67,7 +67,7 @@ void cont_shutdown(); /* Compat function */ -int cont_get_cond(uint8 addr, cont_cond_t *cond); +int cont_get_cond(uint8 addr, cont_cond_t *cond) __attribute__((deprecated)); /* Set a controller callback for a button combo; set addr=0 for any controller */ typedef void (*cont_btn_callback_t)(uint8 addr, uint32 btns); Modified: kos/kernel/arch/dreamcast/include/dc/maple/mouse.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple/mouse.h 2009-02-03 18:28:53 UTC (rev 621) +++ kos/kernel/arch/dreamcast/include/dc/maple/mouse.h 2009-02-03 18:32:27 UTC (rev 622) @@ -47,7 +47,7 @@ } mouse_state_t; /* Old maple interface */ -int mouse_get_cond(uint8 addr, mouse_cond_t *cond); +int mouse_get_cond(uint8 addr, mouse_cond_t *cond) __attribute__((deprecated)); /* Init / Shutdown */ int mouse_init(); Modified: kos/kernel/arch/dreamcast/include/dc/maple.h =================================================================== --- kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-03 18:28:53 UTC (rev 621) +++ kos/kernel/arch/dreamcast/include/dc/maple.h 2009-02-03 18:32:27 UTC (rev 622) @@ -357,25 +357,25 @@ int maple_compat_resolve(uint8 addr, maple_device_t **dev, uint32 funcs); /* Retrieve function code... */ -uint32 maple_device_func(int port, int unit); +uint32 maple_device_func(int port, int unit) __attribute__((deprecated)); /* First with a given function code... */ -uint8 maple_first_device(int code); +uint8 maple_first_device(int code) __attribute__((deprecated)); /* First controller */ -uint8 maple_first_controller(); +uint8 maple_first_controller() __attribute__((deprecated)); /* First mouse */ -uint8 maple_first_mouse(); +uint8 maple_first_mouse() __attribute__((deprecated)); /* First keyboard */ -uint8 maple_first_kb(); +uint8 maple_first_kb() __attribute__((deprecated)); /* First LCD unit */ -uint8 maple_first_lcd(); +uint8 maple_first_lcd() __attribute__((deprecated)); /* First VMU */ -uint8 maple_first_vmu(); +uint8 maple_first_vmu() __attribute__((deprecated)); /* NOP now */ #define maple_rescan_bus(Q) /* NADA */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 18:28:57
|
Revision: 621 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=621&view=rev Author: ljsebald Date: 2009-02-03 18:28:53 +0000 (Tue, 03 Feb 2009) Log Message: ----------- More examples claned to not use the old Maple API. Modified Paths: -------------- kos/examples/dreamcast/modem/basic/example1.c kos/examples/dreamcast/parallax/bubbles/bubbles.c kos/examples/dreamcast/pvr/pvrmark/pvrmark.c kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c kos/examples/dreamcast/sound/hello-mp3/mp3test.c kos/examples/dreamcast/sound/hello-ogg/vorbistest.c kos/examples/dreamcast/vmu/vmu_pkg/vmu.c Modified: kos/examples/dreamcast/modem/basic/example1.c =================================================================== --- kos/examples/dreamcast/modem/basic/example1.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/modem/basic/example1.c 2009-02-03 18:28:53 UTC (rev 621) @@ -14,11 +14,21 @@ int buttonPressed(int button) { - cont_cond_t controller; + maple_device_t *cont; + cont_state_t *state; - cont_get_cond(maple_addr(0, 0), &controller); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(controller.buttons & button); + if (cont) + { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + { + return state->buttons & button; + } + } + + return 0; } int main() Modified: kos/examples/dreamcast/parallax/bubbles/bubbles.c =================================================================== --- kos/examples/dreamcast/parallax/bubbles/bubbles.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/parallax/bubbles/bubbles.c 2009-02-03 18:28:53 UTC (rev 621) @@ -169,8 +169,8 @@ } void do_sphere_test() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; int mode = 0; int a_was_down = 0; @@ -186,15 +186,16 @@ else sphere_frame_trans(); - addr = maple_first_controller(); - if (addr == 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; - if (cont_get_cond(addr, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { return; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (a_was_down) continue; a_was_down = 1; mode ^= 1; Modified: kos/examples/dreamcast/pvr/pvrmark/pvrmark.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark/pvrmark.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark/pvrmark.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c =================================================================== --- kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2009-02-03 18:28:53 UTC (rev 621) @@ -229,10 +229,10 @@ } /* Handle controller input */ -static uint8 mcont = 0; void check_controller() { static int up_moved = 0, down_moved = 0, a_pressed = 0, y_pressed = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; if ((!(sndoggvorbis_isplaying())) && (lst_playing != -1)) { @@ -249,14 +249,14 @@ start(lst_entries[lst_playing].fn); } } - - if (!mcont) { - mcont = maple_first_controller(); - if (!mcont) { return; } - } - if (cont_get_cond(mcont, &cond)) { return; } - if (!(cond.buttons & CONT_DPAD_UP)) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) { return; } + + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return; } + + if (state->buttons & CONT_DPAD_UP) { if ((framecnt - up_moved) > 10) { if (selected > 0) { selected--; @@ -267,7 +267,7 @@ up_moved = framecnt; } } - if (!(cond.buttons & CONT_DPAD_DOWN)) { + if (state->buttons & CONT_DPAD_DOWN) { if ((framecnt - down_moved) > 10) { if (selected < (num_entries - 1)) { selected++; @@ -279,7 +279,7 @@ down_moved = framecnt; } } - if (cond.ltrig > 0) { + if (state->ltrig > 0) { if ((framecnt - up_moved) > 10) { // selected -= 14; selected -= 10; @@ -289,7 +289,7 @@ up_moved = framecnt; } } - if (cond.rtrig > 0) { + if (state->rtrig > 0) { if ((framecnt - down_moved) > 10) { // selected += 14; selected += 10; @@ -301,11 +301,11 @@ down_moved = framecnt; } } - if (!(cond.buttons & CONT_B) && sndoggvorbis_isplaying()) { + if ((state->buttons & CONT_B) && sndoggvorbis_isplaying()) { stop(); } - if (!(cond.buttons & CONT_Y)) { + if (state->buttons & CONT_Y) { if ((framecnt - y_pressed) > 10) { strcat(workstring,curdir); @@ -323,7 +323,7 @@ y_pressed=framecnt; } - if (!(cond.buttons & CONT_A) && !load_queued) { + if ((state->buttons & CONT_A) && !load_queued) { if ((framecnt - a_pressed) > 10) { if (!strcmp(entries[selected].fn, "Error!")) Modified: kos/examples/dreamcast/sound/hello-mp3/mp3test.c =================================================================== --- kos/examples/dreamcast/sound/hello-mp3/mp3test.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/hello-mp3/mp3test.c 2009-02-03 18:28:53 UTC (rev 621) @@ -25,7 +25,8 @@ int main(int argc, char **argv) { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; print_d("mp3 Decoder Library Example Program\n\n"); @@ -45,24 +46,30 @@ while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; - if (!(cond.buttons & CONT_Y)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { - printf("main: restarting oggvorbis\r\n"); - mp3_stop(); - mp3_start("/rd/test.mp3",0); + state = (cont_state_t *)maple_dev_status(cont); + if (!state) + break; + if (state->buttons & CONT_START) + break; + if (state->buttons & CONT_Y) + { + printf("main: restarting mp3\r\n"); + mp3_stop(); + mp3_start("/rd/test.mp3",0); + } + // timer_spin_sleep(10); <-- causes infinite loop sometimes! + thd_sleep(10); + /* bitratenew=sndoggvorbis_getbitrate(); + if (bitratenew != bitrateold) + { + printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); + bitrateold = bitratenew; + } */ } - // timer_spin_sleep(10); <-- causes infinite loop sometimes! - thd_sleep(10); - /* bitratenew=sndoggvorbis_getbitrate(); - if (bitratenew != bitrateold) - { - printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); - bitrateold = bitratenew; - } */ } mp3_stop(); Modified: kos/examples/dreamcast/sound/hello-ogg/vorbistest.c =================================================================== --- kos/examples/dreamcast/sound/hello-ogg/vorbistest.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/hello-ogg/vorbistest.c 2009-02-03 18:28:53 UTC (rev 621) @@ -23,7 +23,8 @@ int main(int argc, char **argv) { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; print_d("Vorbis Decoder Library Example Program\n\n"); @@ -43,24 +44,30 @@ while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; - if (!(cond.buttons & CONT_Y)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (cont) { - printf("main: restarting oggvorbis\r\n"); - sndoggvorbis_stop(); - sndoggvorbis_start("/rd/test.ogg",0); + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + break; + if (state->buttons & CONT_START) + break; + if (state->buttons & CONT_Y) + { + printf("main: restarting oggvorbis\r\n"); + sndoggvorbis_stop(); + sndoggvorbis_start("/rd/test.ogg",0); + } + // timer_spin_sleep(10); <-- causes infinite loop sometimes! + thd_sleep(10); + bitratenew=sndoggvorbis_getbitrate(); + if (bitratenew != bitrateold) + { + printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); + bitrateold = bitratenew; + } } - // timer_spin_sleep(10); <-- causes infinite loop sometimes! - thd_sleep(10); - bitratenew=sndoggvorbis_getbitrate(); - if (bitratenew != bitrateold) - { - printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); - bitrateold = bitratenew; - } } sndoggvorbis_stop(); Modified: kos/examples/dreamcast/vmu/vmu_pkg/vmu.c =================================================================== --- kos/examples/dreamcast/vmu/vmu_pkg/vmu.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/vmu/vmu_pkg/vmu.c 2009-02-03 18:28:53 UTC (rev 621) @@ -9,6 +9,7 @@ any other VMU file from the BIOS menus. */ #include <kos.h> +#include <kos/string.h> extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -53,19 +54,20 @@ } int wait_start() { - uint8 cont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; for(;;) { new_vmu(); - - cont = maple_first_controller(); - if (cont == 0) continue; - if (cont_get_cond(cont, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) return 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 15:59:44
|
Revision: 620 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=620&view=rev Author: ljsebald Date: 2009-02-03 15:59:40 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Updating another bunch of examples to not use the old Maple API. Modified Paths: -------------- kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c kos/examples/dreamcast/libdream/keyboard/keyboard.c kos/examples/dreamcast/libdream/lcd/lcd.c kos/examples/dreamcast/libdream/mouse/mouse.c kos/examples/dreamcast/libdream/spu/spu.c kos/examples/dreamcast/libdream/ta/ta.c kos/examples/dreamcast/libdream/vmu/vmu.c Modified: kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c 2009-02-03 15:59:40 UTC (rev 620) @@ -47,8 +47,8 @@ }; int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Get basic stuff initialized */ pvr_init(¶ms); @@ -62,14 +62,16 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c 2009-02-03 15:59:40 UTC (rev 620) @@ -103,8 +103,8 @@ }; int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init(¶ms); @@ -126,14 +126,16 @@ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c 2009-02-03 15:59:40 UTC (rev 620) @@ -103,8 +103,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init(¶ms); @@ -130,14 +130,16 @@ /* Set up the texture */ loadtxr("/rd/NeHe.pcx", &texture[0]); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c 2009-02-03 15:59:40 UTC (rev 620) @@ -116,16 +116,16 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean xp = GL_FALSE; GLboolean yp = GL_FALSE; GLboolean blend = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); - printf("nehe06 beginning\n"); + printf("nehe08 beginning\n"); /* Get basic stuff initialized */ glKosInit(); @@ -152,40 +152,42 @@ loadtxr("/rd/glass.pcx", &texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) z -= 0.02f; - if (!(cond.buttons & CONT_B)) + if (state->buttons & CONT_B) z += 0.02f; - if (!(cond.buttons & CONT_X) && !xp) { + if ((state->buttons & CONT_X) && !xp) { xp = GL_TRUE; filter += 1; if (filter > 1) filter = 0; } - if (cond.buttons & CONT_X) + if (!(state->buttons & CONT_X)) xp = GL_FALSE; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; blend = !blend; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) + if (state->buttons & CONT_DPAD_LEFT) yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) + if (state->buttons & CONT_DPAD_RIGHT) yspeed += 0.01f; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c 2009-02-03 15:59:40 UTC (rev 620) @@ -7,6 +7,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <GL/gl.h> #include <GL/glu.h> #include <pcx/pcx.h> @@ -113,12 +114,12 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean yp = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); printf("nehe09 beginning\n"); @@ -150,28 +151,30 @@ /* Set up the texture */ loadtxr("/rd/Star.pcx", &texture[0]); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) tilt -= 0.5f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) tilt += 0.5f; - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) zoom -= 0.2f; - if (!(cond.buttons & CONT_B)) + if (state->buttons & CONT_B) zoom += 0.2f; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; twinkle = !twinkle; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c 2009-02-03 15:59:40 UTC (rev 620) @@ -122,16 +122,13 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean xp = GL_FALSE; GLboolean yp = GL_FALSE; - GLboolean ap = GL_FALSE; - GLboolean bp = GL_FALSE; - GLboolean blend = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); printf("nehe16 beginning\n"); @@ -167,42 +164,44 @@ loadtxr("/rd/crate.pcx", &texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (z >= -15.0f) z -= 0.02f; } - if (!(cond.buttons & CONT_B)) { + if (state->buttons & CONT_B) { if (z <= 0.0f) z += 0.02f; } - if (!(cond.buttons & CONT_X) && !xp) { + if ((state->buttons & CONT_X) && !xp) { xp = GL_TRUE; - fogType = ( ++fogType ) % 3; - glFogi( GL_FOG_MODE, fogMode[fogType] ); - printf("%s\n", cfogMode[fogType]); + fogType = (fogType + 1) % 3; + glFogi( GL_FOG_MODE, fogMode[fogType] ); + printf("%s\n", cfogMode[fogType]); } - if (cond.buttons & CONT_X) + if (!(state->buttons & CONT_X)) xp = GL_FALSE; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; fog = !fog; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) + if (state->buttons & CONT_DPAD_LEFT) yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) + if (state->buttons & CONT_DPAD_RIGHT) yspeed += 0.01f; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c 2009-02-03 15:59:40 UTC (rev 620) @@ -9,6 +9,7 @@ #include <kos.h> #include <stdio.h> +#include <stdlib.h> #include <math.h> #include <GL/gl.h> #include <GL/glu.h> @@ -298,14 +299,14 @@ /* Vertex buffer size 512K */ 512*1024 }; -#define NOT_LAST (cond.buttons & last) +#define NOT_LAST !(state->buttons & last) extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; uint16 last = CONT_A; xrot = yrot = zrot = 0.0f; @@ -320,51 +321,51 @@ glKosInit(); initGL(); - c = maple_first_controller(); - printf("Entering main loop\n"); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_A) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph1; last = CONT_A; } - if (!(cond.buttons & CONT_X) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_X) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph2; last = CONT_X; } - if (!(cond.buttons & CONT_Y) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_Y) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph3; last = CONT_Y; } - if (!(cond.buttons & CONT_B) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_B) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph4; last = CONT_B; } - if (!(cond.buttons & CONT_DPAD_UP)) - xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) - xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) - yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) - yspeed += 0.01f; - if (cond.rtrig > 0x7f) + if (state->buttons & CONT_DPAD_UP) + xspeed -= 0.01f; + if (state->buttons & CONT_DPAD_DOWN) + xspeed += 0.01f; + if (state->buttons & CONT_DPAD_LEFT) + yspeed -= 0.01f; + if (state->buttons & CONT_DPAD_RIGHT) + yspeed += 0.01f; + if (state->rtrig > 0x7f) zspeed += 0.01f; - if (cond.ltrig > 0x7f) + if (state->ltrig > 0x7f) zspeed -= 0.01f; - /* Begin frame */ glKosBeginFrame(); Modified: kos/examples/dreamcast/libdream/keyboard/keyboard.c =================================================================== --- kos/examples/dreamcast/libdream/keyboard/keyboard.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/keyboard/keyboard.c 2009-02-03 15:59:40 UTC (rev 620) @@ -1,29 +1,30 @@ #include <kos.h> void kb_test() { - uint8 mcont, mkb; - cont_cond_t cond; + maple_device_t *cont, *kbd; + cont_state_t *state; int k, x = 20, y = 20+24; printf("Now doing keyboard test\n"); while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; - mkb = maple_first_kb(); - if (!mkb) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + kbd = maple_enum_type(0, MAPLE_FUNC_KEYBOARD); + if (!kbd) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return; } - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); /* Check for keyboard input */ /* if (kbd_poll(mkb)) { @@ -33,6 +34,11 @@ /* Get queued keys */ while ( (k = kbd_get_key()) != -1) { + if (k == 27) { + printf("ESC pressed\n"); + return; + } + if (k > 0xff) printf("Special key %04x\n", k); @@ -44,13 +50,8 @@ y += 24; } } - - if (k == 27) { - printf("ESC pressed\n"); - break; - } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/lcd/lcd.c =================================================================== --- kos/examples/dreamcast/libdream/lcd/lcd.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/lcd/lcd.c 2009-02-03 15:59:40 UTC (rev 620) @@ -12,19 +12,20 @@ /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int check_start() { - uint8 mcont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) return 0; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return 0; } - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return 1; } Modified: kos/examples/dreamcast/libdream/mouse/mouse.c =================================================================== --- kos/examples/dreamcast/libdream/mouse/mouse.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/mouse/mouse.c 2009-02-03 15:59:40 UTC (rev 620) @@ -1,45 +1,47 @@ #include <kos.h> void mouse_test() { - mouse_cond_t mcond; - cont_cond_t cond; - uint8 mcont, mmouse; + maple_device_t *cont, *mouse; + cont_state_t *cstate; + mouse_state_t *mstate; int c = 'M', x = 20, y = 20; printf("Now doing mouse test\n"); while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; - mmouse = maple_first_mouse(); - if (!mmouse) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE); + if (!mouse) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + cstate = (cont_state_t *)maple_dev_status(cont); + if (!cstate) { printf("Error getting controller status\n"); return; } - if (!(cond.buttons & CONT_START)) { + if (cstate->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); /* Check for mouse input */ - if (mouse_get_cond(mmouse, &mcond) < 0) + mstate = (mouse_state_t *)maple_dev_status(mouse); + if (!mstate) continue; /* Move the cursor if applicable */ - if (mcond.dx || mcond.dy || mcond.dz) { + if (mstate->dx || mstate->dy || mstate->dz) { vid_clear(0,0,0); - x += mcond.dx; - y += mcond.dy; - c += mcond.dz; + x += mstate->dx; + y += mstate->dy; + c += mstate->dz; bfont_draw(vram_s + (y*640+x), 640, 0, c); } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/spu/spu.c =================================================================== --- kos/examples/dreamcast/libdream/spu/spu.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/spu/spu.c 2009-02-03 15:59:40 UTC (rev 620) @@ -32,23 +32,24 @@ } void wait_start() { - uint8 mcont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/ta/ta.c =================================================================== --- kos/examples/dreamcast/libdream/ta/ta.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/ta/ta.c 2009-02-03 15:59:40 UTC (rev 620) @@ -6,18 +6,20 @@ /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int check_start() { - uint8 mcont = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) return 0; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return 0; - - if (!(cond.buttons & CONT_START)) { + } + + if (state->buttons & CONT_START) { printf("Pressed start\n"); return 1; } @@ -26,7 +28,6 @@ } - /* A little test program -- creates twelve rainbow polygons and moves them around over a color-shifting background. */ typedef struct { Modified: kos/examples/dreamcast/libdream/vmu/vmu.c =================================================================== --- kos/examples/dreamcast/libdream/vmu/vmu.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/vmu/vmu.c 2009-02-03 15:59:40 UTC (rev 620) @@ -10,7 +10,7 @@ /* Draws one file entry, along with its "description" in the boot rom file manager. */ int y1 = 20+36; -void draw_one(uint8 addr, char *fn, uint16 hdrblock) { +void draw_one(maple_device_t *addr, char *fn, uint16 hdrblock) { bfont_draw_str(vram_s+y1*640+10, 640, 0, "File "); bfont_draw_str(vram_s+y1*640+10+5*12, 640, 0, fn); @@ -31,7 +31,7 @@ /* We only do the monochrome one here to avoid having to parse through the FAT. */ -void draw_icondata(uint8 addr, uint16 block) { +void draw_icondata(maple_device_t *addr, uint16 block) { uint8 buf[512], *icon; uint16 *buf16 = (uint16*)buf, *vr = vram_s + 20*640+20; uint16 monoicon; @@ -62,7 +62,8 @@ /* The full read test */ void vmu_read_test() { int i, n, drawn = 0; - uint8 addr = maple_first_vmu(), *ent; + maple_device_t *addr = maple_enum_type(0, MAPLE_FUNC_MEMCARD); + uint8 *ent; uint8 buf[512]; uint16 *buf16 = (uint16*)buf, dirblock, dirlength, *ent16; @@ -128,7 +129,7 @@ /* Do VMU read test */ vmu_read_test(); - usleep(5 * 1000 * 1000); + thd_sleep(5 * 1000); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 02:22:12
|
Revision: 619 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=619&view=rev Author: ljsebald Date: 2009-02-03 01:33:58 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Removing the old Maple API from a bunch of examples. Modified Paths: -------------- kos/examples/dreamcast/2ndmix/2ndmix.c kos/examples/dreamcast/cpp/clock/clock.cc kos/examples/dreamcast/cpp/dcplib/fnt_test.cc kos/examples/dreamcast/cpp/gltest/gltest.cpp kos/examples/dreamcast/cpp/modplug_test/example.cpp kos/examples/dreamcast/kgl/basic/gl/gltest.c kos/examples/dreamcast/kgl/basic/scissor/scissor.c kos/examples/dreamcast/kgl/basic/texenv/texenv.c kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c kos/examples/dreamcast/kgl/basic/vq/vq-example.c kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp Added Paths: ----------- kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m Modified: kos/examples/dreamcast/2ndmix/2ndmix.c =================================================================== --- kos/examples/dreamcast/2ndmix/2ndmix.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/2ndmix/2ndmix.c 2009-02-03 01:33:58 UTC (rev 619) @@ -780,7 +780,8 @@ /* Main program: init and loop drawing polygons */ int main() { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; printf("2ndMix/KallistiOS starting\n"); @@ -797,10 +798,14 @@ printf("Starting display\n"); while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; + if((cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER)) != NULL) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state == NULL) + break; + if(state->buttons & CONT_START) + break; + } draw_one_frame(); } Modified: kos/examples/dreamcast/cpp/clock/clock.cc =================================================================== --- kos/examples/dreamcast/cpp/clock/clock.cc 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/clock/clock.cc 2009-02-03 01:33:58 UTC (rev 619) @@ -120,27 +120,29 @@ case, but it's nice and verbose. */ int read_input () { - uint8 mcont = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) - { - return 0; - } + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(!cont) + { + return 0; + } /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond)) - { - printf("Error getting controller status\n"); - return 1; - } + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + { + printf("Error getting controller status\n"); + return 1; + } - if (!(cond.buttons & CONT_START)) - { - printf("Pressed start\n"); - return 1; - } + if(state->buttons & CONT_START) + { + printf("Pressed start\n"); + return 1; + } + return 0; } Modified: kos/examples/dreamcast/cpp/dcplib/fnt_test.cc =================================================================== --- kos/examples/dreamcast/cpp/dcplib/fnt_test.cc 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/dcplib/fnt_test.cc 2009-02-03 01:33:58 UTC (rev 619) @@ -161,63 +161,61 @@ pvr_scene_finish (); } - /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int read_input () { - uint8 mcont = 0; + maple_device_t *cont; + cont_state_t *state; static bool aHeldDown = false; static bool bHeldDown = false; - cont_cond_t cond; - - if (!mcont) - { - mcont = maple_first_controller(); - if (!mcont) - { - printf("No controllers attached\n"); - return 1; - } - } - + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(!cont) + { + return 0; + } + /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond)) - { - printf("Error getting controller status\n"); - return 1; - } + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + { + printf("Error getting controller status\n"); + return 1; + } + + if(state->buttons & CONT_START) + { + printf("Pressed start\n"); + return 1; + } - if (!(cond.buttons & CONT_START)) - { - printf("Pressed start\n"); - return 1; - } + if(state->buttons & CONT_A) + { + if(!aHeldDown) + { + aHeldDown = true; + switchFont (); + } + } + else + { + aHeldDown = false; + } - if (!(cond.buttons & CONT_A)) - { - if (!aHeldDown) - { - aHeldDown = true; - switchFont (); - } - } + if(state->buttons & CONT_B) + { + if(!bHeldDown) + { + bHeldDown = true; + switchFilterMode (); + } + } else - { - aHeldDown = false; - } - if (!(cond.buttons & CONT_B)) - { - if (!bHeldDown) - { - bHeldDown = true; - switchFilterMode (); - } - } - else - { - bHeldDown = false; - } + { + bHeldDown = false; + } + return 0; } Modified: kos/examples/dreamcast/cpp/gltest/gltest.cpp =================================================================== --- kos/examples/dreamcast/cpp/gltest/gltest.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/gltest/gltest.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -150,8 +150,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; float r = 0.0f; float dr = 2.0f; float z = -14.0f; @@ -193,20 +193,21 @@ new Cube(0.0f, 5.0f, 0.0f), new Cube(0.0f, -5.0f, 0.0f) }; - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) z -= 0.1f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) z += 0.1f; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { /* If manual rotation is requested, then stop the automated rotation */ dr = 0.0f; @@ -214,13 +215,13 @@ cubes[i]->rotate(- 2.0f); r -= 2.0f; } - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + 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 (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/cpp/modplug_test/example.cpp =================================================================== --- kos/examples/dreamcast/cpp/modplug_test/example.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/modplug_test/example.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -25,8 +25,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; uint8 *mod_buffer; uint32 hnd; char filename[]="/rd/test.s3m"; @@ -83,9 +83,10 @@ while(1) { /* Check key status */ - c = maple_first_controller(); - if (cont_get_cond(c, &cond) >= 0) { - if (!(cond.buttons & CONT_START)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + if(state && state->buttons & CONT_START) break; } Added: kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m =================================================================== (Binary files differ) Property changes on: kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: kos/examples/dreamcast/kgl/basic/gl/gltest.c =================================================================== --- kos/examples/dreamcast/kgl/basic/gl/gltest.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/gl/gltest.c 2009-02-03 01:33:58 UTC (rev 619) @@ -97,8 +97,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; float r = 0.0f; float dr = 2; float z = -14.0f; @@ -141,28 +141,30 @@ while(1) { /* Check key status */ - c = maple_first_controller(); - if (c) { - if (cont_get_cond(c, &cond) < 0) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + if(!state) { printf("Error reading controller\n"); } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) z -= 0.1f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) z += 0.1f; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { /* If manual rotation is requested, then stop the automated rotation */ dr = 0.0f; r -= 2.0f; } - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + if (state->buttons & CONT_DPAD_RIGHT) { dr = 0.0f; r += 2.0f; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/kgl/basic/scissor/scissor.c =================================================================== --- kos/examples/dreamcast/kgl/basic/scissor/scissor.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/scissor/scissor.c 2009-02-03 01:33:58 UTC (rev 619) @@ -231,8 +231,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; static GLboolean ap = GL_FALSE; /* Initialize KOS */ @@ -251,33 +251,34 @@ printf("A button selects demo.\n"); printf(" %s\n", demo[selected]); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (cond.buttons & CONT_DPAD_UP) + if (!(state->buttons & CONT_DPAD_UP)) y-=8; if (y < -224) y = -224; - if (cond.buttons & CONT_DPAD_DOWN) + if (!(state->buttons & CONT_DPAD_DOWN)) y+=8; if (y > 448) y = 448; - if (cond.buttons & CONT_DPAD_LEFT) + if (!(state->buttons & CONT_DPAD_LEFT)) x+=8; if (x > 632) x = 632; - if (cond.buttons & CONT_DPAD_RIGHT) + if (!(state->buttons & CONT_DPAD_RIGHT)) x-=8; if (x < -288) x = -288; /* Demo select button */ - if (!(cond.buttons & CONT_A) && !ap) { + if ((state->buttons & CONT_A) && !ap) { ap = GL_TRUE; selected++; selected %= NUM_DEMOS; printf(" %s\n", demo[selected]); } - if (cond.buttons & CONT_A) + if (!(state->buttons & CONT_A)) ap = GL_FALSE; Modified: kos/examples/dreamcast/kgl/basic/texenv/texenv.c =================================================================== --- kos/examples/dreamcast/kgl/basic/texenv/texenv.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/texenv/texenv.c 2009-02-03 01:33:58 UTC (rev 619) @@ -81,8 +81,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; int trans = 0; GLuint texture1, texture2, texture3; @@ -108,16 +108,17 @@ loadtxr("/rd/crate.pcx", &texture2); loadtxr_tga("/rd/kgl.tga", &texture3); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c =================================================================== --- kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c 2009-02-03 01:33:58 UTC (rev 619) @@ -84,8 +84,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLuint texture; /* Initialize KOS */ @@ -109,14 +109,15 @@ glClearColor(0.4f, 0.4f, 0.8f, 1.0f); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/basic/vq/vq-example.c =================================================================== --- kos/examples/dreamcast/kgl/basic/vq/vq-example.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/vq/vq-example.c 2009-02-03 01:33:58 UTC (rev 619) @@ -106,8 +106,8 @@ } int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init_defaults(); @@ -134,15 +134,22 @@ return 0; } - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (!cont) { + printf("No controllers connected\n"); + break; + } + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c =================================================================== --- kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c 2009-02-03 01:33:58 UTC (rev 619) @@ -38,14 +38,18 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (cont_get_cond(addr, &cond) < 0) - return 0; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(cond.buttons & CONT_START); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + return state->buttons & CONT_START; + } + + return 0; } pvr_poly_hdr_t hdr; Modified: kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c =================================================================== --- kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c 2009-02-03 01:33:58 UTC (rev 619) @@ -1,6 +1,6 @@ /* KallistiGL ##version## - pvrmark.c + quadmark.c (c)2002 Dan Potter, Paul Boese */ @@ -38,14 +38,18 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (cont_get_cond(addr, &cond) < 0) - return 0; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(cond.buttons & CONT_START); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + return state->buttons & CONT_START; + } + + return 0; } pvr_poly_hdr_t hdr; @@ -74,12 +78,12 @@ x = rand() % 640; y = rand() % 480; z = rand() % 100 + 1; - size = rand() % 50; - col = (rand () % 255) * 0.00391f; + size = rand() % 50 + 1; + col = (rand () % 255)*0.00391f; glColor3f(col, col, col); - glVertex3f(x-size, y+size, z); glVertex3f(x-size, y-size, z); + glVertex3f(x+size, y-size, z); glVertex3f(x+size, y+size, z); } glEnd(); @@ -92,7 +96,7 @@ time_t start; void switch_tests(int ppf) { printf("Beginning new test: %d polys per frame (%d per second at 60fps)\n", - ppf, ppf * 60); + ppf*2, ppf*2*60); avgfps = -1; polycnt = ppf; } @@ -103,7 +107,7 @@ now = time(NULL); if (now >= (start + 5)) { start = time(NULL); - printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps)); + printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps * 2)); switch(phase) { case PHASE_HALVE: if (avgfps < 55) { @@ -123,7 +127,7 @@ break; case PHASE_DECR: if (avgfps < 55) { - switch_tests(polycnt - 20); + switch_tests(polycnt - 30); } else { printf(" Entering PHASE_FINAL\n"); phase = PHASE_FINAL; @@ -158,3 +162,4 @@ } + Modified: kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c =================================================================== --- kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c 2009-02-03 01:33:58 UTC (rev 619) @@ -207,8 +207,8 @@ } void do_sphere_test() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; int mode = 0; int a_was_down = 0; @@ -225,15 +225,16 @@ else sphere_frame_trans(); - addr = maple_first_controller(); - if (addr == 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; - if (cont_get_cond(addr, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { return; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (a_was_down) continue; a_was_down = 1; mode ^= 1; Modified: kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp =================================================================== --- kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -309,7 +309,7 @@ static float max[2] = { 0.0, 0.0 }; static float min[2] = { 255.0, 255.0 }, center[2]; -static void do_joy(cont_cond_t *cond) { +static void do_joy(cont_state_t *cond) { JOYINFO joy; @@ -352,19 +352,20 @@ } static GLboolean yp = GL_FALSE; -int do_controller(uint8 c) { +int do_controller(maple_device_t *cont) { static int dpad = 0; static int dpadrep = DPAD_REPEAT_INTERVAL; - static cont_cond_t cond; + cont_state_t *state; /* Check key status */ - if (cont_get_cond(c, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) return 0; /* DPAD Menu controls */ - if (!(cond.buttons & CONT_DPAD_UP)) { + if (state->buttons & CONT_DPAD_UP) { if (dpad == 0) { dpad |= 0x1000; if (help) { @@ -375,7 +376,7 @@ } else dpad &= ~0x1000; - if (!(cond.buttons & CONT_DPAD_DOWN)) { + if (state->buttons & CONT_DPAD_DOWN) { if (dpad == 0) { dpad |= 0x0100; if (help) { @@ -386,7 +387,7 @@ } else dpad &= ~0x0100; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { if (dpad == 0) { dpad |= 0x0001; if (help) { @@ -397,7 +398,7 @@ } else dpad &= ~0x0001; - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + if (state->buttons & CONT_DPAD_RIGHT) { if (dpad == 0) { dpad |= 0x0010; if (help) { @@ -419,18 +420,18 @@ dpadrep = DPAD_REPEAT_INTERVAL; /* Help toggle */ - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; help = !help; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; /* Reset view */ - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) reset_view(); - do_joy(&cond); + do_joy(state); v = (float)(velocity/100.0f); @@ -443,16 +444,15 @@ extern uint8 romdisk[]; int main(void) { - uint8 c; pvr_stats_t stats; + maple_device_t *cont; do_init(); - - c = maple_first_controller(); printf("[DCTunnel] Entering Main Loop\n"); while(1) { - if (!do_controller(c)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont && !do_controller(cont)) break; /* Begin frame */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <los...@us...> - 2008-12-04 23:39:51
|
Revision: 618 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=618&view=rev Author: lostgeneration Date: 2008-12-04 23:39:46 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Added pngwio.o to libpng OBJS Thanks for pointing that out steven_h. Seems to not break anything. Modified Paths: -------------- kos-ports/libpng/Makefile Modified: kos-ports/libpng/Makefile =================================================================== --- kos-ports/libpng/Makefile 2008-11-19 01:27:59 UTC (rev 617) +++ kos-ports/libpng/Makefile 2008-12-04 23:39:46 UTC (rev 618) @@ -1,7 +1,7 @@ TARGET = libpng.a OBJS = pngerror.o pnggccrd.o pngget.o pngmem.o pngpread.o pngread.o \ pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngvcrd.o \ - pngwrite.o pngwtran.o pngwutil.o png.o readpng.o kos_img.o + pngwrite.o pngwtran.o pngwutil.o png.o readpng.o kos_img.o pngwio.o KOS_CFLAGS += -I../include/png \ -I../include/zlib \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |