 |
SpritesMind.Net Sega Megadrive/Genesis development
|
| View previous topic :: View next topic |
| Author |
Message |
colonthree Interested
Joined: 07 Aug 2009 Posts: 18
|
Posted: Thu Feb 03, 2011 2:48 am Post subject: Hello world. It works, but... (controller interrupts?) |
|
|
So I finally got a little hello world working in emulators, thought I'd try it on hardware via Everdrive, and to my delight, it worked!
A little HELLO WORLD is printed in the top left of plane a
However, for some reason, the Licensed by Sega Enterprises Ltd remains in the middle of the screen. Not only that, but it's fontset is replaced by mine (loaded into VRAM:0).
Is it my responsibilty to clear the message off the screen? Is it a requirement to initialise VRAM always?
Thanks
Last edited by colonthree on Sat Apr 02, 2011 1:34 am; edited 3 times in total |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2006
|
Posted: Thu Feb 03, 2011 3:17 am Post subject: |
|
|
Yes, you should assume that you have to do EVERYTHING. Clear memory, clear vram, set the palettes, init the joysticks, etc. This is a console, and an old one at that. If it wasn't for the TMSS in the "newer" MegaDrives, you would really HAVE to do EVERYTHING yourself. |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1953 Location: Estonia, Mahtra village
|
Posted: Thu Feb 03, 2011 4:05 pm Post subject: |
|
|
on MD1 you indeed have to clear up everything otherwise nothing will work  _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
Eke Very interested
Joined: 28 Feb 2007 Posts: 677 Location: Toulouse, France
|
Posted: Thu Feb 03, 2011 9:42 pm Post subject: |
|
|
| Quote: | So I finally got a little hello world working in emulators, thought I'd try it on hardware via Everdrive, and to my delight, it worked!
|
Have you tried Everdrive SDK ?
http://krikzz.com/pub/support/everdrive-md/SDK/everdrive-sdk-v1.0.7z
It's very to install and it took me less than 5 minutes to compile my first app, by copying one of the example and adapt to your project. There are some basic functions to call in main() then you are set.
Here is a basic Hello world for example:
| Code: | int main()
{
VDP_init();
VDP_loadFont(font_base, 0);
VDP_setPaletteColor(0, 15, 0xfff);//font color (white)
VDP_setPaletteColor(0, 0, 0x505);//bg color (purple)
//clean screen
VDP_fillTileRect(APLAN, 0, 0, 0, 40, 27);
VDP_fillTileRect(BPLAN, 0, 0, 0, 40, 27);
VDP_drawText(APLAN, "Hello World !", 0, 2, 10);
while(1) VDP_waitVSync();
return 0;
} |
|
|
| Back to top |
|
 |
colonthree Interested
Joined: 07 Aug 2009 Posts: 18
|
Posted: Tue Feb 08, 2011 12:48 am Post subject: |
|
|
Sorry for the late reply,
Thanks for all the info!
About the everdrive sdk; i'll definitely be looking into it (right now.)
Although I'm trying to use asm over c, I'm sure the sdk will be useful
On that topic, why does the sdk come with some assembly apps if it's all in c? |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1953 Location: Estonia, Mahtra village
|
Posted: Tue Feb 08, 2011 7:23 am Post subject: |
|
|
because ASM rules
More likely because ASM is faster and its useful for some intensive tasks. _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
ob1 Very interested
Joined: 06 Dec 2006 Posts: 364 Location: Aix-en-Provence, France
|
Posted: Wed Feb 09, 2011 5:14 am Post subject: |
|
|
| TmEE co.(TM) wrote: | because ASM rules  |
Indeed !!!
 |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2006
|
Posted: Wed Feb 09, 2011 6:34 am Post subject: |
|
|
Well, it rules on GOOD processors like the 68000.
It really bites on pathetic processors like the x86.  |
|
| Back to top |
|
 |
colonthree Interested
Joined: 07 Aug 2009 Posts: 18
|
Posted: Wed Feb 09, 2011 9:21 pm Post subject: |
|
|
I'm familiar with the potential for efficiency when coding with asm, otherwise probably no one would still use it (?)
I was asking why there are asm compilers bundled with the sdk, considering all of the code files are written in c. Are the asm comilers still required to compile c to binary somewhere inbetween? (I've only ever compiled C on windows outputting to the command prompt.)
Oh yeah and another question came to mind;
| Quote: | | If it wasn't for the TMSS in the "newer" MegaDrives, you would really HAVE to do EVERYTHING yourself. |
What do you have to do without the TMSS? I used to have a commented disassembly of the MD2 'OS' which I guess would answer this (but I can only seem to find the bindump of it) anyone have a copy of a commented one? THanks again  |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2006
|
Posted: Wed Feb 09, 2011 10:15 pm Post subject: |
|
|
| colonthree wrote: | I'm familiar with the potential for efficiency when coding with asm, otherwise probably no one would still use it (?)
I was asking why there are asm compilers bundled with the sdk, considering all of the code files are written in c. Are the asm comilers still required to compile c to binary somewhere inbetween? (I've only ever compiled C on windows outputting to the command prompt.) |
No such thing as an "asm compiler", but there are assemblers. The assembler converts assembly language into machine language. And yes, an assembler is needed because the compiler outputs assembly language.
| Quote: | Oh yeah and another question came to mind;
| Quote: | | If it wasn't for the TMSS in the "newer" MegaDrives, you would really HAVE to do EVERYTHING yourself. |
What do you have to do without the TMSS? |
What do you have to do? Everything, of course.
Regardless of TMSS, you should always just do EVERYTHING. Clear work ram, clear vram, clear the PSG, clear the FM, set up the VDP, yada, yada, yada...
| Quote: | I used to have a commented disassembly of the MD2 'OS' which I guess would answer this (but I can only seem to find the bindump of it) anyone have a copy of a commented one? THanks again  |
http://www.atariage.com/forums/topic/98540-sega-genesis-programming/page__view__findpost__p__1193987 |
|
| Back to top |
|
 |
colonthree Interested
Joined: 07 Aug 2009 Posts: 18
|
Posted: Wed Feb 09, 2011 10:25 pm Post subject: |
|
|
| Chilly Willy wrote: | | No such thing as an "asm compiler", but there are assemblers. The assembler converts assembly language into machine language. And yes, an assembler is needed because the compiler outputs assembly language. |
Ah yes, I initially wrote "assembler" and for some reason it didn't look right so I changed it....
And good to clear that up, I assumed the C was somehow compiled directly into correctly formatted binary.
| Chilly Willy wrote: | Regardless of TMSS, you should always just do EVERYTHING. Clear work ram, clear vram, clear the PSG, clear the FM, set up the VDP, yada, yada, yada...
|
Ah so if I code with MD2 in mind, doing all the proper clearing/initialising, it should be more or less 'backwards compatible' with MD1? I'm sure there will be differences in some areas that I've read about but forgot now! >_<
Clearly, I still have much to learn
And thanks for the link, that's where I'd originally found it  |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2006
|
Posted: Wed Feb 09, 2011 11:58 pm Post subject: |
|
|
| colonthree wrote: | | Chilly Willy wrote: | | No such thing as an "asm compiler", but there are assemblers. The assembler converts assembly language into machine language. And yes, an assembler is needed because the compiler outputs assembly language. |
Ah yes, I initially wrote "assembler" and for some reason it didn't look right so I changed it....
And good to clear that up, I assumed the C was somehow compiled directly into correctly formatted binary. |
Lots of words that look "funny" in programming.
And there are some compilers that do output machine code... and others that output some odd intermediate language that's neither assembly, nor a "normal" language.
| Quote: | | Chilly Willy wrote: | Regardless of TMSS, you should always just do EVERYTHING. Clear work ram, clear vram, clear the PSG, clear the FM, set up the VDP, yada, yada, yada...
|
Ah so if I code with MD2 in mind, doing all the proper clearing/initialising, it should be more or less 'backwards compatible' with MD1? I'm sure there will be differences in some areas that I've read about but forgot now! >_< |
And emulators as well.
| Quote: | And thanks for the link, that's where I'd originally found it  |
No problemo. |
|
| Back to top |
|
 |
colonthree Interested
Joined: 07 Aug 2009 Posts: 18
|
Posted: Fri Feb 11, 2011 1:41 pm Post subject: |
|
|
Thanks again Chilly Willy!
I have other more general questions relating to programming in assembly. Probably best not to start a new thread since it follows on from my hello world thing.
I'm wondering about why programmers seem to do things like use bsr for subroutines that are only run once at the start of the ROM to initialise parts of hardware, why not just code inline? And I read it is best to use registers whenever possible over RAM access, but if you're just doing one operation to the data before putting it back into RAM, isn't it going to actually take longer?
example:
| Code: | move.l $ff0000, d0
addq.l #1, d0
move.l d0, $ff0000 |
I have seen things similar to that^ in code, but for this particular example is it not more efficient to avoid registers and just use:
i.e. how do you decide when it is best to use registers over RAM access?
I have lots of little questions like this, since this is my first asm language!
too long/noob questions/didn't read above:
How did you guys learn good asm coding practices? from example/others' work? by reading lots of asm docs? trial and error?
Any links to materials on this much appreciated! If not I'll have to keep bugging you all with noob questions!!
I've read quite a bit of md asm docs a lot of them might mention that it's better to use one programming method over another, but not fully go in detail why. |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2006
|
Posted: Fri Feb 11, 2011 9:36 pm Post subject: |
|
|
| colonthree wrote: |
I'm wondering about why programmers seem to do things like use bsr for subroutines that are only run once at the start of the ROM to initialise parts of hardware, why not just code inline? And I read it is best to use registers whenever possible over RAM access, but if you're just doing one operation to the data before putting it back into RAM, isn't it going to actually take longer?
example:
| Code: | move.l $ff0000, d0
addq.l #1, d0
move.l d0, $ff0000 |
I have seen things similar to that^ in code, but for this particular example is it not more efficient to avoid registers and just use:
i.e. how do you decide when it is best to use registers over RAM access? |
The example may be compiled code - compilers often generate code that may look "odd" in assembly. Back when I worked on the Amiga, I could tell which compiler someone used just by looking at the assembly code. Compilers like to leave intermediate results in registers just in case they're used elsewhere. In the above example, maybe $ff0000 + 1 was used in the code a little further down, so it saved time OVERALL to add 1 in d0 instead of adding 1 to the memory.
| Quote: |
I have lots of little questions like this, since this is my first asm language!
too long/noob questions/didn't read above:
How did you guys learn good asm coding practices? from example/others' work? by reading lots of asm docs? trial and error?
|
All of the above.
Practice... lots and lots of practice.
| Quote: |
Any links to materials on this much appreciated! If not I'll have to keep bugging you all with noob questions!!
I've read quite a bit of md asm docs a lot of them might mention that it's better to use one programming method over another, but not fully go in detail why. |
I just tell people to get the user manual for the CPU, then look at open source that's available. |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1953 Location: Estonia, Mahtra village
|
Posted: Sat Feb 12, 2011 6:09 pm Post subject: |
|
|
I had prior ASM knowledge before doing 68K so it was easier for me. I started with programming in QB45 but my programs were not always fastest so I needed something to enhance them and found out how to use x86 ASM in the programs. I used some tutorials specifically made to get ASM work in the programs. Simple stuff and well written, good for me ^^
Then when I looked at MD I saw BEX and tried it but did not like it as its too far form QB45 so I went with ASM. I grabbed a bunch of Amiga newbie docs to see how code looks like and what is possible and here I am  _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|