Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - [Coding competition 2011] New Duel by losinggeneration

Reply to topic

Rate this entry!

1 (poor) 3% 3%
2 15% 15%
3 23% 23%
4 23% 23%
5 11% 11%
6 19% 19%
7 3% 3%
8 0% 0%
9 (excellent) 0% 0%
This poll has expired.
Author Message
  • Joined: 31 Jan 2011
  • Posts: 24
  • Location: Iowa, USA
Reply with quote
[Coding competition 2011] New Duel by losinggeneration
Post Posted: Wed Mar 23, 2011 2:22 pm
New Duel

losinggeneration wrote
This is an SMS game for the 2011 SMSPower coding competition. It is a start of a platformer similar to Marshmallow Duel.


------------------------
[Admin note: this thread was split from the general competitions thread. Original content follows...]

When I started attempting SMS/GG coding, I probably didn't do enough research because I didn't know about z88dk which may have saved me some trouble. Instead I've been using SDCC. I started out by getting something minimal up and running, and from there I built a small utility library to do some low level things. After that I started learning how the VDP worked with regards to drawing backgrounds which was easy enough. I stumbled around with sprites for some time (3-5 days) until I realized I overlooked an obvious problem, I was writing to the wrong VDP memory address. So what I currently have is a level drawn, a slight animation of a portion of the background, a sprite character with varying degrees of success for some basic animation on it, and some basic movement (very basic, just a left/right button test.)

The only thing that makes my project kind of interesting is how little Z80 assembly I actually used. It's used for the startup code and in two functions which I've avoided in favor of a better optimized macro. Everything else is in C.

Here's a couple examples:
void clear_vram() {
   uint16_t x;

   /* clear palette */
   tms9918a_cram_set_address(0x00);
   for(x = 0; x < 0x20; ++x) {
      tms9918a_write(0);
   }

   /* clear the entire vram */
   tms9918a_vram_set_write_address(0);
   for(x = 0; x < 0x4000; ++x)
      tms9918a_write(0);
}

Here's a library function for setting a VDP address to follow by a write:
#define tms9918a_ctrl(d) out(VDP_CTRL, d)

void tms9918a_vram_set_write_address(uint16_t addr) {
   tms9918a_ctrl(0x00FF & addr);          /* write the first (lower) byte */
   tms9918a_ctrl((0x4000 | (0x3F00 & addr)) >> 8); /* write the second (upper) byte */
}

This is a small example of checking the input (using an SDCC optimization):
#define A_LEFT    (1 << 2)
input1 = ~io_ab_reg;

if(input1 & A_LEFT) {
   player1.x -= 1;
}


It's been a fun project, and like I said before, I've learned a lot by kind of doing things my own way and not leveraging existing work. I'll also have a much better starting position for future projects. I'm hesitant to post an actual build.
Maxim wrote
Now, as a newbie you have to realise that the first few things you produce are not going to be much good - I know mine weren't. So do yourself a favour, and the rest of the world, and don't release them.

SMS_NewDuel.png (13.88 KB)
SMS_NewDuel.png
SMS_NewDuel-wip.gif (21.49 KB)
SMS_NewDuel-wip.gif

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12392
  • Location: London
Reply with quote
Post Posted: Wed Mar 23, 2011 5:35 pm
Note that my comment was referring to people doing simple changes (e.g. Hello World with replaced text, BMP2Tile demo with changed pictures...) rather than original work. My first two releases were static screens, yours at least moves :)
  View user's profile Send private message Visit poster's website
  • Joined: 31 Jan 2011
  • Posts: 24
  • Location: Iowa, USA
Reply with quote
Post Posted: Wed Mar 23, 2011 6:57 pm
Maxim wrote
Note that my comment was referring to people doing simple changes (e.g. Hello World with replaced text, BMP2Tile demo with changed pictures...) rather than original work. My first two releases were static screens, yours at least moves :)

I struggled on various things with getting any kind of movement until I started to really understand how the VDP was expecting things. I'll go ahead and attach my current work (which doesn't have the lava movement enabled currently. If you look carefully the movement is actually made by using horizontal flipping of the lava sprites.) Basically it's one of the last good builds with my experimentation with sprite movement, doing updates during vsyncs, and input handling. Left/Right work on the joystick to move the character.

I included everything that's needed to build the source. The only gottcha is that I used SDCC 3.0.0 for the compiler but, it requires an updated makebin because of a couple bugs in the released version. Also, no clue if this will build on anything other then Linux. I'm sure it could build on any system that SDCC is available for, but I've never tried on anything else.

Hopefully I didn't do anything too brain-dead in the code to warrant mocking :)
newduel-wip.zip (34.51 KB)

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12392
  • Location: London
Reply with quote
Post Posted: Thu Mar 24, 2011 9:25 am
I suggest you keep working on it. There seem to be a lot of sprite glitches going on - are you updating VRAM in the VBlank only? You might want to cache the tilemap and sprite table in RAM. The sprites at 0,0 are due to not terminating the sprite table with a Y=0xd0.
  View user's profile Send private message Visit poster's website
  • Joined: 31 Jan 2011
  • Posts: 24
  • Location: Iowa, USA
Reply with quote
Post Posted: Thu Mar 24, 2011 1:46 pm
Last night I actually switched to only updating during the vblank and most (maybe all) of the graphics glitches went away. I had read that, but during initial testing I didn't because I wasn't even using the vblank initially. I had read that I needed to terminate the sprite table, but I've put it off until I have both characters drawing.

In any case, with that, what seems to be better input handling, and a couple other small changes have given me hope that perhaps I can get at least a very basic version with platform navigation finished by the deadline.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Feb 2006
  • Posts: 501
  • Location: Belo Horizonte, MG, Brazil
Reply with quote
Post Posted: Sun Mar 27, 2011 3:30 pm
Very nice (and successful) attempt to make a SMS program using SDCC; over time, this could progress into a nice game.
  View user's profile Send private message Visit poster's website
  • Joined: 31 Jan 2011
  • Posts: 24
  • Location: Iowa, USA
Reply with quote
Post Posted: Mon Mar 28, 2011 4:02 am
haroldoop wrote
Very nice (and successful) attempt to make a SMS program using SDCC; over time, this could progress into a nice game.
Thanks. It's been an idea I've been meaning to work on for ages, and thought this would be a good chance to try to implement it. The SMS (and eventually GG too) seem like a pretty good fit for this type of game.

After a certain point I realized I wouldn't have much (dare I say any :P) of a chance at winning, but I did put a solid two months of work into learning the hardware and getting the compiler to cooperate. I'm quite happy with what I was able to produce using this compiler and feel it will give me a great starting point for future projects with the SMS/GG :)
  View user's profile Send private message Visit poster's website
  • Joined: 05 Jul 2009
  • Posts: 33
Reply with quote
Post Posted: Wed Apr 06, 2011 12:21 am
Low marks as a game, but I definitely appreciate the learning curve of raw code on a vintage architecture, and this does beat half the stuff I've seen done on NES in 4 months of formal instruction, so definitely not bad for 2 months of independent research!
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 12392
  • Location: London
Reply with quote
Post Posted: Sat Apr 09, 2011 10:29 pm
Obviously not intended to win, this one :) Graphics are a fun but could do with an artist rather than a programmer with Paint... the rest is waiting to arrive. The guy could have a bunch more animations for the ladder-climbing, falling, etc.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!