|
Post by socram8888 on Dec 3, 2009 11:23:25 GMT -5
I was wondering over months, with the next idea: Load programs from Genesis' internal RAM.I know there's only 64kB available, but I think it's enough for little experiments. Then I made this program. I never tryed it (i haven't got a Genesis development cartridge Do you think it works, or it will hang? ' DATA PORT MAP ' Bit 0~7 : Data ' Bit 8 : Clock ' Bit 9 : Boot dim ramoffset as long ' RAM pointer dim dataport as integer ' Current integer at data bus dim clocked as integer ' New data? ramoffset& = &hFF2000 ' First byte available for Ramdisk clocked = 0 ' Byte not loaded locate 1, 4 print "*** Sega MegaDrive RAMDISK ***" print print "for BasiEgaXorz development" print "Programmed by S4X8.tk" print print "No bytes loaded (" + str$(&hFFFFFF - ramoffset&) + " bytes free)" dataport = peekint(&h20000) ' Get data from &h20000 while not(dataport.9) ' No boot order received if ((dataport.8) + (clocked = 0)) = 2 then ' There are new data in bus poke ramoffset&, dataport ' Meter byte en la RAM ramoffset& = ramoffset& + 1 ' Increase byte pointer in 1 locate 6, 0 print str$(ramoffset& - &hFF2000) + " bytes loaded (" + str$(&hFFFFFF - ramoffset&) + " bytes free) " locate 7, 0 print "Last byte: 0x" + right$(hex$(curint), 2) ' Show the last read byte end if
if ((dataport.8 = 0) + (clocked)) = 2 then ' No data on bus clocked = 0 end if
dataport = peekint(&h20000) ' Update data from &h20000 wend locate 10, 9 print "* Switching to RAM *" goto ramdisk ' Boot from RAM ramdisk: ' This goes to 0xFF2000 (a section of the RAM), using a little trick See you soon
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Dec 3, 2009 13:17:13 GMT -5
Hi, From looking at your code, it looks like you're trying to read some sequential data from some IO port, and then you're copying it to internal SRAM, and then changing execution to that code in SRAM. I don't think your code will work . Some of the reasons are that there needs to be some better handshaking between the Genesis and the host (your computer). Handshaking will tell the host exactly when the Genesis has pulled off the valid data from the bus, so that it can send the next byte. Or else, the computer will clock in data too fast, unless you insert some kind of delay. Anyways, I think there is some more stuff wrong with it, but I think you got the concept down very good. As for running homebrewed code on the real hardware, I already have a solution for everyone, but I have not released it yet. Probably some time at the middle of this month, I will work on it, and release it in a week. You will not need to have a developer cartridge, or a flash cartridge, or any kind of custom cartridge for my solution . You will need to build a custom parallel port circuit though (consisting of a 74xx157 -> 2-1x4 multiplexer right?, and two D-Flip Flops). Other than that, you will also need a copy of Sonic 1 or Sonic 2 (no modification of the cartridge either). More details later when I release the host side software.
|
|
|
Post by Tom Maneiro on Dec 4, 2009 1:14:52 GMT -5
Ew... parallel port. Need more of these. Any plans to take the Genesis to the XXI century with some USB love?
|
|
|
Post by socram8888 on Dec 4, 2009 5:24:23 GMT -5
Yeah. I'm using the variable "clocked" as handshaking. Also the parallel port can run up to 21MHz, but I know that's too much for a 68k that runs at only 7.91Mhz (PAL version) I made a program using the controller instead of the parallel port (A button is a 0 bit and B is 1 bit, C is for start running). It WORKED (it said "helo" and then counted from 1 to 10), but it's too slow to load programs to RAM (just 1 byte per second, due to the 60Hz controller speed) I'm going to implement a CRC. Then the port map is now: - Bit 0~7 from &h20000 is data
- Bit 8 from &h20000 is clock
- Bit 9 from &h20000 is for start execution
- Bit 10~15 from &h20000 is for CRC (the last 6 bits from the CRC)
Nice, not? @tom Maneiro: I used sometimes HID USB, but I think it's too slow for this purposes. However, I want to buy a USB HID, and then try it. @oompa loompa: My method is simpler (no additional hardware), and cheaper. I tryed to make a Flash Cart, but flash are too expensive, and most of these are SMD T.T See you soon
|
|
|
Post by Mairtrus on Dec 4, 2009 12:27:42 GMT -5
This topic is really interesting for me...
Actually, me and a couple of friends (which have the electronical knowledge that I don't...) we're making a cartridge which consist of a 128 kb of SRAM memory striped from an old motherboard (I'm having troubles to find EEPROMS in the locals electronic stores...), an Atmel microcontroler, and a 16-bits I/O port, but currently we have a lot of problems to solve after to consider it a finished product.
Anyway, I'm looking forward to your solution, Devster...
@tom: I think somebody tried that on SpritesMind forums (or tried to try...), but the USB has a really high resources consumption, so it's nearly to the impossible add a fast I/O port to our Gennys. At least, no without added hardware...
|
|
|
Post by socram8888 on Dec 4, 2009 16:32:49 GMT -5
I forgot that the parallel port has got only 12 outputs, not 16! Then, the port map is the next: - DATA0 to DATA7 : the data
- STROBE : clock
- INITIALIZE : start the program
- LINEFEED : change addres
- SELECT : parity bit
The "change address" changes the address from the RAM to the VRAM. This allows to load tiles directly to the VRAM, and then the images don't waste program RAM. I'm currently working in the circuit. See you soon
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Dec 4, 2009 23:01:24 GMT -5
Yeah. I'm using the variable "clocked" as handshaking. Also the parallel port can run up to 21MHz, but I know that's too much for a 68k that runs at only 7.91Mhz (PAL version) I made a program using the controller instead of the parallel port (A button is a 0 bit and B is 1 bit, C is for start running). It WORKED (it said "helo" and then counted from 1 to 10), but it's too slow to load programs to RAM (just 1 byte per second, due to the 60Hz controller speed) I'm going to implement a CRC. Then the port map is now: - Bit 0~7 from &h20000 is data
- Bit 8 from &h20000 is clock
- Bit 9 from &h20000 is for start execution
- Bit 10~15 from &h20000 is for CRC (the last 6 bits from the CRC)
Nice, not? @tom Maneiro: I used sometimes HID USB, but I think it's too slow for this purposes. However, I want to buy a USB HID, and then try it. @oompa loompa: My method is simpler (no additional hardware), and cheaper. I tryed to make a Flash Cart, but flash are too expensive, and most of these are SMD T.T See you soon Wow, it worked! Yea, I think we're all interested now . Like, how did you get the bootloader to run on the Genesis? Is this through a Sega CD or something? And what's the parallel port circuit like? I'm very interested in the hardware, if it's very minimal from what I've planned . I'm thinking you're using DTACK from the 68k bus to hold the bus, and load new data somewhere, either the controller, or some input buffer to the data bus You can access the controller faster than 60Hz. The 60Hz is just there for 6-button controllers because 6-button controllers need the delay to reset itself I kind of figure that if this is going to be a homebrew solution, then everything has to be homebrew . USB devices are not easily accessible to hobbyists, is what I mean. A D-Flip Flop, and a 74xx157 (stolen from a controller) is pretty easy to get for hobbyists. But I know what you mean, If you don't have access to a parallel port, then you're pretty much out of luck . You could use one of your old computers though , BEX works on Windows 98 from what I've heard. I have access to a surplus of USB microcontrollers, and can sell some USB->Genesis chips just for this bootloader, all depends on how big of a demand . A purchased flash cart (tototek?) is always the way to go because you won't be limited by the 64k work ram and 64k vram contraint, ad they're USB. Just wait for the initial release - sometime the middle of this month
|
|
|
Post by socram8888 on Dec 5, 2009 4:52:05 GMT -5
Yeah. I'm using the variable "clocked" as handshaking. Also the parallel port can run up to 21MHz, but I know that's too much for a 68k that runs at only 7.91Mhz (PAL version) I made a program using the controller instead of the parallel port (A button is a 0 bit and B is 1 bit, C is for start running). It WORKED (it said "helo" and then counted from 1 to 10), but it's too slow to load programs to RAM (just 1 byte per second, due to the 60Hz controller speed) I'm going to implement a CRC. Then the port map is now: - Bit 0~7 from &h20000 is data
- Bit 8 from &h20000 is clock
- Bit 9 from &h20000 is for start execution
- Bit 10~15 from &h20000 is for CRC (the last 6 bits from the CRC)
Nice, not? @tom Maneiro: I used sometimes HID USB, but I think it's too slow for this purposes. However, I want to buy a USB HID, and then try it. @oompa loompa: My method is simpler (no additional hardware), and cheaper. I tryed to make a Flash Cart, but flash are too expensive, and most of these are SMD T.T See you soon Wow, it worked! Yea, I think we're all interested now . Like, how did you get the bootloader to run on the Genesis? Is this through a Sega CD or something? And what's the parallel port circuit like? I'm very interested in the hardware, if it's very minimal from what I've planned . I'm thinking you're using DTACK from the 68k bus to hold the bus, and load new data somewhere, either the controller, or some input buffer to the data bus You can access the controller faster than 60Hz. The 60Hz is just there for 6-button controllers because 6-button controllers need the delay to reset itself I kind of figure that if this is going to be a homebrew solution, then everything has to be homebrew . USB devices are not easily accessible to hobbyists, is what I mean. A D-Flip Flop, and a 74xx157 (stolen from a controller) is pretty easy to get for hobbyists. But I know what you mean, If you don't have access to a parallel port, then you're pretty much out of luck . You could use one of your old computers though , BEX works on Windows 98 from what I've heard. I have access to a surplus of USB microcontrollers, and can sell some USB->Genesis chips just for this bootloader, all depends on how big of a demand . A purchased flash cart (tototek?) is always the way to go because you won't be limited by the 64k work ram and 64k vram contraint, ad they're USB. Just wait for the initial release - sometime the middle of this month No. The controller version worked succesfully on an emulator (Fusion), not the parallel port version. But don't try to run a normal homebrew: you need to compile the homebrew in a special way. However, I'm currently working on the circuit for the parallel port version. The source of the "controller version" is the next: Button A = 0, button B = 1, button C = run dim ramoffset as long ' Puntero de la RAM dim curbyte as integer ' Byte actual dim curmult as integer ' Numero de bits en curbyte ramoffset& = &hFF2000 ' Primer byte disponible para la Ramdisk locate 1, 4 print "*** Sega MegaDrive RAMDISK ***" print print "for BasiEgaXorz development" print "Programmed by S4X8.tk" print print "No bytes loaded (" + str$(&hFFFFFF - ramoffset&) + " bytes free)" curint = 0 ' Poner byte actual a 0 curmult = 0 ' Poner contador de bits a 0 while joypad(0).5 = 0 ' Mientras no se pulse C if (joypad(0).6 + joypad(0).4) = 1 then ' Si está pulsado A o B curint = curint * 2 ' Correr los bits if joypad(0).4 = 1 then ' Si está pulsado B... curint = curint + 1 ' ... añadir un 1 end if if curmult = 7 then ' Si ya están todos los bits colocados poke ramoffset&, curint ' Meter byte en la RAM ramoffset& = ramoffset& + 1 ' Aumentar el puntero de la RAM locate 6, 0 print str$(ramoffset& - &hFF2000) + " bytes loaded (" + str$(&hFFFFFF - ramoffset&) + " bytes free) " locate 7, 0 print "Last byte: 0x" + right$(hex$(curint), 2) ' Notificar del último byte leído curint = 0 ' Resetear byte curmult = 0 ' Resetear contador de bits else ' Si no están todos los bits colocados curmult = curmult + 1 ' Aumentar la cantidad de bits end if while (joypad(0).4 + joypad(0).6) <> 0 ' Hasta que no se suelte el botón A y/o el botón B wend end if wend locate 10, 9 print "* Switching to RAM *" goto ramdisk ramdisk:
This code uses the controller instead of a parallel port in order to read data. (sorry, but it's commented in spanish :/ ) But wait! There's a special method to compile it. I made a program in FreeBASIC to copy "basic.s" (the program), "basicstr.s" (the strings), "basicdat.s" (the files to include) and "basicasm.cni" (the base) from BEX folder to another folder named "copy". Here is the code in FreeBASIC: shell "mkdir copy" shell "del /q copy\*" shell "copy /b basic* copy\*" shell "bASMX.EXE " + command$
Compile it and rename the resultant executable to "ASMX.EXE". Then, go to BEX folder and rename the real ASMX.EXE to bASMX.EXE, and put the fake ASMX.EXE in the BEX folder. Now, open my program in BasiEgaXorz, compile it, and you will get "basic.bin" in the BEX folder, and the original assembler source code in "copy" folder. Measure the size of "basic.bin" file. Mine is 12.921 bytes. Now we calculate the padding from the end of "basic.bin" to the RAM address where the RAMDISK is storing the data, after the address &hFF1FFF. Then, create a file with &hFEED87 bytes at &h00. I used my hex editor, HxD. Save it as "spacer.bin" in the BEX folder. Go to the "copy" folder and open "basic.s" in Notepad. The end of the file should look as this: __LABEL_ramdisk: forever: bra forever
EVEN
__LONG_RAMOFFSET EQU $FF0030 __INTEGER_CURBYTE EQU $FF0034 __INTEGER_CURMULT EQU $FF0036 __INTEGER_CURINT EQU $FF0038 HEAPSTART EQU $FF003A include basicstr.s EVEN
include basicdat.s EVEN
__DATA_Pendcode: END
Add the file spacer.bin before the basicdat.s include EVEN, and move the label RAMDISK before the _DATA_Pendcode: label. Now, it should look as this: forever: bra forever
EVEN
__LONG_RAMOFFSET EQU $FF0030 __INTEGER_CURBYTE EQU $FF0034 __INTEGER_CURMULT EQU $FF0036 __INTEGER_CURINT EQU $FF0038 HEAPSTART EQU $FF003A include basicstr.s EVEN
include basicdat.s EVEN
incbin spacer.bin
__LABEL_ramdisk: __DATA_Pendcode: END
Now, the label RAMDISK points to &hFF2000, the RAM address where I am storing the program.Move every files in the "copy" folder to the BEX folder. Then, create a file named "try.bat" with the next contents: basmx.exe -e -b -d SegaCart -d TILE_UNSET=0 -d TILE_SET=1 basic.s -x basic.bin It will compile the current program to basic.bin. Open basic.bin in an HEX editor, and trim the &h00 until you get a &hFF, and then save it. THAT'S ALL! Now the program can store data to &hFF2000 and then run from it To try it it really works, run and press C. The program will hang and you receive and error. Now, let's try with a loop: 60 FE in hex, so 01100000 11111110 in binary, and ABBAAAAA BBBBBBBA in the controller. Press C and... no error!!! IT WORKED! A LOOP! Pretty nice for a 14 years old guy, isn't?
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Dec 8, 2009 13:19:28 GMT -5
Yes, that is pretty good When you said that you were able to transfer data from the controller port, I thought you meant that you already had some kind of external hardware already set up . It sure takes a long time to program something onto SRAM by pushing controller buttons So is there any way to bring this onto real hardware? I think we're all interested in getting stuff running on real hardware very easy and very cheap . And something other than a SegaCD bootloader as well . If it means that you will need to have a flash or eeprom cartridge to run the bootloader program, then it's probably a lot of work, but don't give up! As I predicted: I haven't started working on the software yet for my solution . I have way too much stuff going on right now
|
|
|
Post by socram8888 on Dec 9, 2009 12:31:26 GMT -5
I can help you in the software. I know how to program in computers (PHP, HTML, JavaScript, FreeBASIC, QBASIC, AutoIT) and in BasiEgaXorz Now in the topic: yes, you need a FLASH chip for the bootloader. But you need only to program a chip the first time! I think it's better to use the controller pad instead of a port in the cartridge: it's easier! No chips, no bus conflicts, easier to implement, etc... Using a RS-232 (COM) port for connected to the Controller 2 port, the connections should be the following (looking on male connectors, from left to right and from top to bottom): Genesis Controller 2 | RS-232 (COM) | Function | Pin 1 | Pin 3 (TXD) | Data Bit | Pin 2 | +5 (Genesis pin 5) | Hardware detection | Pin 3 | 4 (DTR) | Clock | Pin 4 | 7 (RTS) | Run |
I made this weekend a little test about COM interfacing using PORT.DLL, and I can set and clear each data line from the COM I'm working now in the new bootloader See you soon
|
|
|
Post by Tom Maneiro on Dec 9, 2009 19:21:45 GMT -5
I love Spanish comments - that's because i'm from Venezuela.
Ah, well, my ol' HP nx9010 should do for the parport thingy - it has one parallel port, and ZERO serial ports. Anyone have experience with those USB<->parport cables? Most of them only works for printers, not for advanced I/O devices.
|
|
|
Post by socram8888 on Dec 10, 2009 5:23:56 GMT -5
@tom Maneiro: yeah, I read it from your profile . I'm Spanish I read somewhere on the Internet, that is possible to emulate a COM through a LPT port (I can't remember where T.T) See you soon PS: I use your Genesis ROM editor
|
|
|
Post by Tiido on Dec 10, 2009 9:02:07 GMT -5
Controller port is definitely very easy to use ofr that, and with good code you can get some over 60KB/sec data transfer speeds using Mask of Destiny's MCD cable. I do this with it : www.youtube.com/watch?v=xh6i4JBXrpA
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Dec 10, 2009 22:37:52 GMT -5
Transmitting data through the RS232 native way requires precision timing if it's to be done through the parallel port. The only way to do that is to have a DOS program. Like Tiido said, there's already a parallel port->genesis cable around too. Just search for mask of destiney on google. His RAM loader runs on the Sega CD, and will load programs into the 256k word RAM. BEX compiles for this word RAM origin if you've already seen
|
|
|
Post by socram8888 on Dec 11, 2009 5:14:41 GMT -5
I use a library named PORT.DLL to control RS-232 using Raw data (for example, instead of put a byte in the address, and then generate the clock, this library allows me to put DTR high, TxD low, etc...) I made an experiment with this library: a christmas light controller by my computer. And it worked See you soon
|
|