eCastos

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
cyrusdevx
DCEmu Newbie
DCEmu Newbie
Posts: 9
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat Oct 10, 2015 9:46 am
Has thanked: 0
Been thanked: 0

eCastos

Post by cyrusdevx »

eCastos

3/17/2016 updated
Status

FTDI Done :D
Image

~ UPDATE ~

Attached: 0.3.0U
proj.rar
updated 0.3.0U
(2.7 MiB) Downloaded 188 times
Preparing for G2 ATA Support :D made an extra 74HC00 by mistake.
I should also mention i have a good enough parts to make 1 complete unit with g2 connector
and 2-3 ones minus g2 port...
Image




eCastos is now taking shape :D, though still very minimal its progress a bit since the OP.
Please download and run on a capable dreamcast plox. let me know!

Also check the "My Help Requests" section of this post :P

Code: Select all


/*		Author: Warren Cyrus ~ DevolutionX
 *		This source code is composed with several kallistios provided examples.
 *		
 *		Additional code was written by the author.
 *		v0.3.0U		02/10/16
 */                                                                                                                                 
                                                                                                                                    
                            CCCCCCCCCCCCC                                           tttt                                            
                         CCC::::::::::::C                                        ttt:::t                                            
                       CC:::::::::::::::C                                        t:::::t                                            
                      C:::::CCCCCCCC::::C                                        t:::::t                                            
    eeeeeeeeeeee     C:::::C       CCCCCC  aaaaaaaaaaaaa      ssssssssss   ttttttt:::::ttttttt       ooooooooooo       ssssssssss   
  ee::::::::::::ee  C:::::C                a::::::::::::a   ss::::::::::s  t:::::::::::::::::t     oo:::::::::::oo   ss::::::::::s  
 e::::::eeeee:::::eeC:::::C                aaaaaaaaa:::::ass:::::::::::::s t:::::::::::::::::t    o:::::::::::::::oss:::::::::::::s 
e::::::e     e:::::eC:::::C                         a::::as::::::ssss:::::stttttt:::::::tttttt    o:::::ooooo:::::os::::::ssss:::::s
e:::::::eeeee::::::eC:::::C                  aaaaaaa:::::a s:::::s  ssssss       t:::::t          o::::o     o::::o s:::::s  ssssss 
e:::::::::::::::::e C:::::C                aa::::::::::::a   s::::::s            t:::::t          o::::o     o::::o   s::::::s      
e::::::eeeeeeeeeee  C:::::C               a::::aaaa::::::a      s::::::s         t:::::t          o::::o     o::::o      s::::::s   
e:::::::e            C:::::C       CCCCCCa::::a    a:::::assssss   s:::::s       t:::::t    tttttto::::o     o::::ossssss   s:::::s 
e::::::::e            C:::::CCCCCCCC::::Ca::::a    a:::::as:::::ssss::::::s      t::::::tttt:::::to:::::ooooo:::::os:::::ssss::::::s
 e::::::::eeeeeeee     CC:::::::::::::::Ca:::::aaaa::::::as::::::::::::::s       tt::::::::::::::to:::::::::::::::os::::::::::::::s 
  ee:::::::::::::e       CCC::::::::::::C a::::::::::aa:::as:::::::::::ss          tt:::::::::::tt oo:::::::::::oo  s:::::::::::ss  
    eeeeeeeeeeeeee          CCCCCCCCCCCCC  aaaaaaaaaa  aaaa sssssssssss              ttttttttttt     ooooooooooo     sssssssssss 

INFO:
	The file main.c is eCastos' core operating facility.
	The included Librarys are supportlib and protolib.
	Supportlib is recycled & slightly altered code from
	SWAT over @ http://www.dc-swat.ru/
	Protolib is written by the Author.

LICENSE:
	PART1:
		The Following Files are NOT MINE: 
		enc28j60.c enc28j60.h g2_bus.c g2_bus.h
		Please visit SWAT over @ http://www.dc-swat.ru/ 
		For this information.
	PART2:
		All Remaining Code is CC4.0 License.
	
libsupport.a:
	This is the core support library.
	Includes drivers for Serial Ethernet Phy
	And G2 BUS ATA Drives.
	Files:
		enc28j60.c	/ enc28j60.h
		g2_bus.c	/ g2_bus.h 
	
libproto.a:
	This is the core library for eCastos. 
	Files:
		proto_sub1.c	/ proto_sub1.h
		proto_sub2.c	/ proto_sub2.h
		proto_sio.c		/ proto_sio.h
		
		
Application:
	
	Features as of the version in the header of this document include.
	HDD:
		G1ATA Hard Drive Support
		EXT2 FileSystem Support
		Device Detection
		Device Initialization
		Device Data (Sync | Flushing)
		FileSystem Initialization
		FileSystem Mount Control
		Preliminary Write Support
		Read And Display Root on G1
		
	SIO:
		Serial Device Check
		Serial Device Initialization
		Serial Device Shutdown
		Serial Device Sync | Flush
		
	PVR:
		Display Initialization
		Display Background
		Display Text Initialization
		Display On Screen Text
		Render Primitives
		Pause Rendering The PVR
		
	GEN:
		Main Program Loop
		Primary Update Function
		MapleBus Controllers
		Controller Input
		Program Execution
		Shutdown Control
		Subelf Display
		State Machine
	
CREDIT WHERE DUE:
	Bluecrab 	- Several Examples from src included in KOS and online @ http://dcemulation.org/
	SWAT	 	- Sources from DreamShell his popular OS
	DanPotter	- G2_bus Code
	
NOTES:
		This is a Work In Progess
		Testing is done over serial with dcload-serial 1.0.4 windows executable and the companion cdr.
		
MAKEFILE_DOC:
	make options:
		all - builds the librarys, subelf, and bootelf
		________________________________________
		^\                all                 /^
		^ \__________________________________/ ^
		^ make sure to build this first if     ^
		^ you used the clean command. librarys ^
		^ are first to be built.               ^
		^______________________________________^
		
		build - builds the subelf, and bootelf
		________________________________________
		^\                build               /^
		^ \__________________________________/ ^
		^ this make command is the one to use  ^
		^ if requiring an executable for       ^
		^ testing on hardware.                 ^
		^______________________________________^
		
		dbg - starts dc-tool.exe and executes the target as elf
		run - starts dc-tool.exe and ececutes the target as bin
		________________________________________
		^\             dbg & run              /^
		^ \__________________________________/ ^
		^ can change in the makefile.          ^
		^ i use my own usb to serial setup     ^
		^ thats why its set to 1500000kbps     ^
		^ change the com port to match ur com# ^
		^______________________________________^
		
		rebuild - cleans the entire source, then executes 'all' and 'build' for a fresh build
		clean - cleans the entire source
		
		[code]
			make rebuild
			make dbg
			
			OR
			
			make rebuild
			make run
			
			OR
			
			make clean
			make all
			make buildrun
			make dbg
		

LIBPROTO Library

proto_sio.h:

[ int initSIO(int baud, int fifo) ]
Sets the parameters for the serial device.
Then detect & initialize the serial device.
[ int stopSIO() ]
Sends Shutdown for the serial device.
[ int flushSIO() ]
Sends pending data and syncs the serial device.

proto_sub1.h:

[ initTXT(int *n) ]
Sets the Encoding.

[ void initBG(char *bg) ]
Loads 'bg' into pvr texture memory.

[ void drawBG() ]
Renders the png and sets the parameters for rendering.

[ initVideo(int disMode, int pixMode) ]
Initializes the video.
Sets up the display with the KOS macros.

[ clearVideo(int r, int g, int b) ]
Clears video with input rgb color.
If in a loop this function can draw the input rgb color indefinitely.

[ printPVR(int x, int y, char *str) ]
Takes the input character string, also taking
the x and y coordinates then automatically
render it starting at top left corner(0=x,0=y)
and typical starting point for printPVR is x=0, y=0.

Code: Select all

			
			//MAX is 20 lines #DISP_HEIGHT-480 / 24 = 20
			//MAX characters is 53 per line #DISP_WIDTH-640 / 12 = 53 rounded down
			
			while (MAGIC_FUNCTION) {
				printPVR(0,0,"HELLO WORLD 		  NOTE: 12 is the font char width");
				printPVR(0,24,"Hello from 2nd line NOTE: 24 is font char height");
			}
			

Recycled: Bluecrab
void drawHLine(int x1, int x2, int y, uint16 c);
void drawVLine(int x, int y1, int y2, uint16 c);
void drawCBox(int x1, int y1, int x2, int y2, uint16 c);
void drawFBox(int x1, int y1, int x2, int y2, uint16 c);

proto_sub2.h:
//FINISH SECTION

[ void mountCTL(char *blkhdd, int state ]);
[ void printDIR(char *dir ]);
[ void printRFS() ]
[ int checkHDD() ]
[ int initHDD() ]
[ int initFS(char *blkhdd) ]
[ int removeFS(char *blkhdd) ]
[ int syncHDD(char *blkhdd) ]
[ int writeToTextFile(char *blkhdd, char *str) ]
[ int writeRTF(char *blkhdd) ]
[ int readRTF(char *blkhdd) ]
[ int executeSub(char *rdsubelf, int bootm) ]
[ void shutDown(char *blkhdd) ]
[/code]

~ My Help Requests ~
[1] Figure out how to make a directory / file browser base with cut, copy, paste, delete.
Last edited by cyrusdevx on Thu Mar 17, 2016 11:52 am, edited 28 times in total.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: eCastos

Post by BlueCrab »

Interesting, but are you actually using an IDE device on G2? The output you have there seems to suggest you're using an IDE device on G1.

Also, SWAT didn't write the G2 IDE code, that was Dan Potter -- it is actually still included in KOS to this day (kernel/arch/dreamcast/navi/navi_ide.c). I wrote the G1 ATA/IDE code, for reference. :wink:

As for PPP, KOS already supports that, if you're using if you use a recent version of KOS out of the official Git repository. If you're not using a recent version (which your output seems to indicate you aren't), I suggest pulling a recent version to work with, and then you'll have PPP support in addons/libppp.

Also, this looks like more of a topic for the Programming Discussion forum than for Developmental Ideas, so off we go...
cyrusdevx
DCEmu Newbie
DCEmu Newbie
Posts: 9
Joined: Sat Oct 10, 2015 9:46 am
Has thanked: 0
Been thanked: 0

Re: eCastos

Post by cyrusdevx »

BlueCrab wrote:Interesting, but are you actually using an IDE device on G2? The output you have there seems to suggest you're using an IDE device on G1.

Also, SWAT didn't write the G2 IDE code, that was Dan Potter -- it is actually still included in KOS to this day (kernel/arch/dreamcast/navi/navi_ide.c). I wrote the G1 ATA/IDE code, for reference. :wink:

As for PPP, KOS already supports that, if you're using if you use a recent version of KOS out of the official Git repository. If you're not using a recent version (which your output seems to indicate you aren't), I suggest pulling a recent version to work with, and then you'll have PPP support in addons/libppp.

Also, this looks like more of a topic for the Programming Discussion forum than for Developmental Ideas, so off we go...
Thanks first off for the fix on topic.
Second yes the hdd is on g1, i will support g2 in the future :)
Thanks for the awesome g1 code btw.

i have the build system 4.9.1 from swats site, but ill update the git directory and rebuild.

i decided to opt for scif.h to support in a future revision. for linking with a host pc and additional software for keyboards, and other forms of data transmit. and end up using the enc28j60.h for internet accessibility as an option for use with keyboards.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: eCastos

Post by BlueCrab »

I think that you're highly unlikely to see anyone building a G2 hard drive interface, considering it is much easier to do on G1. G1 is just a straight through wire connection, whereas G2 requires not only wiring a pretty difficult adapter, but also the board that is required too (also you don't have DMA support on G2 and such too), but I suppose it doesn't hurt at all. :wink:

Also, be careful with GCC 4.9.1. I've had some weird issues with badly generated code with 4.8.x and later due to some weird optimization problems... I personally recommend 4.7.3 (which is the newest version that has a patch in the KOS repo itself).
cyrusdevx
DCEmu Newbie
DCEmu Newbie
Posts: 9
Joined: Sat Oct 10, 2015 9:46 am
Has thanked: 0
Been thanked: 0

Re: eCastos

Post by cyrusdevx »

BlueCrab wrote:I think that you're highly unlikely to see anyone building a G2 hard drive interface, considering it is much easier to do on G1. G1 is just a straight through wire connection, whereas G2 requires not only wiring a pretty difficult adapter, but also the board that is required too (also you don't have DMA support on G2 and such too), but I suppose it doesn't hurt at all. :wink:

Also, be careful with GCC 4.9.1. I've had some weird issues with badly generated code with 4.8.x and later due to some weird optimization problems... I personally recommend 4.7.3 (which is the newest version that has a patch in the KOS repo itself).
ok back to 4.7.3 lol, was on that prior but got issues with cygwin for other reasons.
also due to swats site refusing to let me redownload 4.7.3 with a passion lol.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: eCastos

Post by BlueCrab »

There are instructions around of how to build the toolchain on Cygwin. Take a look around the forum here, I'm sure you'll find what you need to build it yourself, rather than downloading a pre-compiled toolchain.
cyrusdevx
DCEmu Newbie
DCEmu Newbie
Posts: 9
Joined: Sat Oct 10, 2015 9:46 am
Has thanked: 0
Been thanked: 0

Re: eCastos

Post by cyrusdevx »

BlueCrab wrote:There are instructions around of how to build the toolchain on Cygwin. Take a look around the forum here, I'm sure you'll find what you need to build it yourself, rather than downloading a pre-compiled toolchain.
its a matter of convenience for me to have a pre-compiled toolchain.
i use my own comp toolchains for netbsd dreamcast and ps2linux. also for other boards.
i was able to download 4.7.3 and rebuild kos from git.

Buildlog:

Code: Select all

CyrusDevX@DevolutionX ~/dc/proj
$ make all
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -Iinclude -c src/sub.c -o build/sub.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -o romdisk/sub.bin  build/sub.o  -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
/opt/toolchains/dc/sh-elf/bin/sh-elf-objcopy -O binary -R .stack romdisk/sub.bin romdisk/sub.bin
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -Iinclude -c src/main.c -o build/main.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -Iinclude -c src/enc28j60.c -o build/enc28j60.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -Iinclude -c src/g2_ide.c -o build/g2_ide.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-ar rcs lib/libsupport.a build/enc28j60.o build/g2_ide.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -Iinclude -c src/proto_sio.c -o build/proto_sio.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-ar rcs lib/libproto.a build/proto_sio.o
genromfs.exe -f romdisk.img -d romdisk -v -x .svn
0    rom 56b81c2f         [0xffffffff, 0xffffffff] 37777777777, sz     0, at 0x0
1    .                    [0x7ef7e9b2, 0x8f83    ] 0040755, sz     0, at 0x20   
1    ..                   [0x7ef7e9b2, 0x23d0d   ] 0040755, sz     0, at 0x40     [link to 0x20    ]
1    background.png       [0x7ef7e9b2, 0x1fd83   ] 0100755, sz 24785, at 0x60   
1    sub.bin              [0x7ef7e9b2, 0x221d4   ] 0100755, sz 346576, at 0x6160
/usr/local/dc/kos/kos/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
/opt/toolchains/dc/sh-elf/bin/sh-elf-gcc lib/libsupport.a  -g -O3 -DFRAME_POINTERS -ml -m4-single-only -ffunction-sections -fdata-sections -I/usr/local/dc/kos/kos/../kos-ports/include -I/usr/local/dc/kos/kos/include -I/usr/local/dc/kos/kos/kernel/arch/dreamcast/include -I/usr/local/dc/kos/kos/addons/include -I/usr/local/dc/kos/kos/../kos-ports/include -D_arch_dreamcast -D_arch_sub_pristine -Wall -g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000 -Wl,--gc-sections -T/usr/local/dc/kos/kos/utils/ldscripts/shlelf.xc -nodefaultlibs -L/usr/local/dc/kos/kos/lib/dreamcast -L/usr/local/dc/kos/kos/addons/lib/dreamcast -L/usr/local/dc/kos/kos/../kos-ports/lib -o build/main.elf  build/main.o romdisk.o   -lkosext2fs -lpng -lz -lm -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
works great :D
cyrusdevx
DCEmu Newbie
DCEmu Newbie
Posts: 9
Joined: Sat Oct 10, 2015 9:46 am
Has thanked: 0
Been thanked: 0

Re: eCastos

Post by cyrusdevx »

Added my first help request.Those with that knowledge, i would greatly appreciate learning this. Thanks
Post Reply