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 2021] SMS-A-Sketch by raphnet

Reply to topic

Rate this entry!

1 (Terrible) 0% 0%
2 0% 0%
3 5% 5%
4 0% 0%
5 0% 0%
6 0% 0%
7 23% 23%
8 41% 41%
9 5% 5%
10 (Excellent) 23% 23%
This poll has expired.
Author Message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14685
  • Location: London
Reply with quote
[Coding competition 2021] SMS-A-Sketch by raphnet
Post Posted: Sat Mar 27, 2021 10:32 pm
https://www.smspower.org/Homebrew/SMSASketch-SMS



Quote
This is a simple demo, where you can use two paddle controllers to draw on the screen, etch-a-sketch style.
Not everyone has a paddle controller, let alone two of them... So two other kinds of controllers are supported:

- Standard controllers. Press 1 to enable/disable drawing, 2 to save, and pause to "shake" the sms-a-sketch screen to erase.

- Sega Mega Mouse (MK-1645): Hold the left button to draw, the middle button to "shake", and the mouse "start button" (the recessed button) to save.

I had been thinking of doing this ever since I wrote code to support paddles in my Donkey.SMS game. I also wanted to learn how tiles are made (bit planes, etc) for another project (run-time tile combining for a sokoban clone) so figuring out how to draw pixels seemed like a good exercise.

I got a bit carried away and added an intro with music, scalable text using a simple vector font, moving knobs the while writing/drawing stuff...

Tested on real hardware using a Japanese SMS and a US Megadrive
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14685
  • Location: London
Reply with quote
Post Posted: Sat Mar 27, 2021 10:34 pm
Awesome! Maybe you can add Graphic Board support too..?
  View user's profile Send private message Visit poster's website
Revo
  • Guest
Reply with quote
Post Posted: Sat Mar 27, 2021 10:51 pm
 
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
Post Posted: Sat Mar 27, 2021 11:05 pm
Maxim wrote
Awesome! Maybe you can add Graphic Board support too..?
Sure, that would be fun! Is the Graphic Board emulated? I don't have one...

I also wanted to support drawing by light gun, but I ran out of time.
  View user's profile Send private message Visit poster's website
Revo
  • Guest
Reply with quote
Post Posted: Sat Mar 27, 2021 11:09 pm
Emulicious and Meka emulate the Graphic Board. (I think)

What about the Sports Pad?
 
  • Joined: 01 Feb 2014
  • Posts: 844
Reply with quote
Post Posted: Mon Mar 29, 2021 7:22 am
This is brilliant. The intro alone would be a worthy competion entry.
  View user's profile Send private message
  • Joined: 01 May 2011
  • Posts: 467
Reply with quote
Post Posted: Mon Mar 29, 2021 3:15 pm
This is a really cool idea for using the paddles. Unfortunately I don't have them to test, but from watching the video, presentationally this looks excellent! Highly impressed!

I agree with previous posters, adding support for Graphics Board and/or Sports Pads would make it a great homebrew to demonstrate generally unsupported peripherals.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3758
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Tue Mar 30, 2021 8:07 pm
Very interesting entry - thanks for posting it!
I think this is a simple demo only apparently - in fact there's a lot of technical things here to see:
- double paddle support (a first?)
- MD mouse support (a first!)
- 360 tiles 4bpp bitmap mode (albeit used as 1bpp here, very uncommon anyway)
- vector font (seriously?!?)
  View user's profile Send private message Visit poster's website
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Tue Mar 30, 2021 10:08 pm
Brilliant! I got one of these for x-mas sometime back in the 80’s.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
Version 1.1 - Sports Pad and Graphics Board
Post Posted: Wed Mar 31, 2021 10:53 pm
Hello!

A new version is now available!

Changes:

- Add support for the Graphics Board
- Add support for the Sports Pad
- Reworked the input layer to add the above.. I am creating something called "inlib" (for input library) which I will share soon.

I could not find a reliable way to auto detect the those two new input devices... it almost worked, but then I tested on real hardware and there were false positives...

So at the Input diagnostics screen, you will have to press PAUSE to cycle through Graphics Board, Sports Pad, and SMS pad. The mouse and paddle are still detected automatically.

Graphics Board tested with Meka and Emulicious. Not on real hardware... anyone has one to try? ;-)

Sports Pad also tested in emulation only, with Meka. Slow mouse movement do not register, and it feels a bit odd... I think that's due to how Mouse->Sports Pad translation is done in Meka? I don't have a physical Sports Pad to compare.
input_diag.png (2.46 KB)
input_diag.png
sms_a_sketch-1.1.zip (135.23 KB)

  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
About the "vector" font
Post Posted: Wed Mar 31, 2021 11:14 pm
sverx wrote
- vector font (seriously?!?)
Yes, I wanted something that would be drawn in strokes! But it's just a hack.

Using inkscape, I drew the font on a grid (screenshot attached). Note that at that point, I had not yet implemented a proper line drawing algorithm, what I had only supported 8 directions. This limitation influenced the font design which is only drawn with 0, 90 and 45 degree lines.

Then I manually encoded each letter using the qweadzxc keys which, on a qwerty keyboard, are laid out in the 8 possible directions around the s:
    { 2, 2, 3, "azxddewqa" }, // a
    { 0, 5, 3, "xxxxxddewqa" }, // b
    { 2, 3, 3, "azxcde" }, // c
    { 2, 3, 3, "azxcddwwwww" }, // d
    { 2, 2, 3, "dqazxcdd" }, // e
    { 1, 5, 1, "zxxdaxxxz" }, // f
    { 2, 0, 3, "aqwedcxxxz" }, // g
    { 0, 5, 3, "xxxxxwwedcxx" }, // h
    { 0, 3, 0, "xxxswwwwsw" }, // i
    { 0, 3, 1, "xxxxzsewwwwwsw" }, // j
    { 0, 5, 2, "xxxxxwweezzcc" }, // k


Like a plotter, the drawing code simply moves a "pen" in the indicated direction by an increment of 1 unit. The length of the unit, in pixels, is what controls the font size. For letters like i and j, the "s" key toggles between pen up and pen down condition.


case 'a': pen_x -= scale; break;
case 'q': pen_x -= scale; pen_y -= scale; break;
case 'w': pen_y -= scale; break;
case 'e': pen_x += scale; pen_y -= scale; break;
case 'd': pen_x += scale; break;
case 'c': pen_x += scale; pen_y += scale; break;
case 'x': pen_y += scale; break;
case 'z': pen_x -= scale; pen_y += scale; break;
case 's': pen_down = !pen_down; break;

All this really isn't space efficient, but it did not matter. It just had to work :-)

My code to draw lines/pixels is somehow slow, but luckily just fast enough for the effect to work. In action it looks like quick handwriting!
font_inkscape.png (42.85 KB)
font_inkscape.png

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14685
  • Location: London
Reply with quote
Post Posted: Wed Mar 31, 2021 11:27 pm
Here's how the graphics board software detects the board:

https://github.com/maxim-zhao/smsgraphicboard/blob/dcc08fdbc0ac46f09144f6905ef0d...

...it looks for U,D,L,R all pressed at once.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
Post Posted: Thu Apr 01, 2021 12:10 am
Maxim wrote
Here's how the graphics board software detects the board:

https://github.com/maxim-zhao/smsgraphicboard/blob/dcc08fdbc0ac46f09144f6905ef0d...

...it looks for U,D,L,R all pressed at once.
Thanks! The waveforms in graphicboard.asm were super helpful when I was trying to learn how to read from one!

I was aware of the detection technique and implemented it. It worked fine, but it became a problem when I added support for the sports pad. The sports pad also returns zeros when there is no movement...

And on real hardware, the Mega drive mouse was being misdetected as the Graphics board (or maybe the paddle was, I'm on longer sure which, it was late yesterday night...)

At some point I thought I had found a clever way to detect the sports pad vs. the graphics pad, but something kept breaking, either in emulation on real hardware. I tried playing around with the order in which I tried to detecting different peripherals, etc... I finally gave up.

This program tries to support too many input devices I think!
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3758
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Apr 01, 2021 12:21 pm
raphnet wrote
Note that at that point, I had not yet implemented a proper line drawing algorithm, what I had only supported 8 directions. This limitation influenced the font design which is only drawn with 0, 90 and 45 degree lines.


It's a good simple approach and I think actually it would work for *any* raster font - you just have to describe each character the same way you did for your own font - but I think it's great that you created your own font.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Oct 2015
  • Posts: 183
  • Location: Ireland
Reply with quote
Post Posted: Fri Apr 02, 2021 4:40 pm
Very original entry. Would be awesome if you could add light gun support if you were going to add to this project :)
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
Version 1.2 - Light gun support
Post Posted: Mon Apr 05, 2021 8:45 am
Hello!

Here is version 1.2 which now also support light guns. It seems to work well in emulators and somehow on real hardware.

Unfortunately I don't have a real Light Phaser for testing, so I hacked together a "Sega Competitor light gun" adapter... The trigger turned out not to be usable (could be my adapter's fault) but the light sensor works.
Still it's very noisy and only registers when the screen is very bright.
light_gun_test1.jpg (98.81 KB)
light_gun_test1.jpg
light_gun_test2.jpg (123.8 KB)
light_gun_test2.jpg
famicom_adapter.jpg (109.83 KB)
famicom_adapter.jpg
sms_a_sketch-1.2.zip (135.5 KB)

  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14685
  • Location: London
Reply with quote
Post Posted: Mon Apr 05, 2021 9:11 am
It does only like very bright screens, especially if you want it to register around the edges where you have the red border.
  View user's profile Send private message Visit poster's website
Revo
  • Guest
Reply with quote
Post Posted: Mon Apr 05, 2021 2:29 pm
Working fine thank you!




Would be nice to be able to plug the light phaser on port controller 2.
 
  • Joined: 07 Mar 2021
  • Posts: 55
Reply with quote
Post Posted: Tue Apr 06, 2021 10:09 am
Yeah ! Nice addition !
  View user's profile Send private message
  • Joined: 12 Oct 2015
  • Posts: 183
  • Location: Ireland
Reply with quote
Post Posted: Tue Apr 06, 2021 9:26 pm
raphnet wrote
Here is version 1.2 which now also support light guns. It seems to work well in emulators and somehow on real hardware.

Awesome! I re-entered + increased my vote :) BTW: did you build this demo using the devkitSMS?
If so then would you pls be able to share your code or Github repo etc? Thanks
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2015
  • Posts: 63
  • Location: Japan
Reply with quote
Post Posted: Tue Apr 06, 2021 11:58 pm
Revo wrote
Working fine thank you!

Yay! It works with the real thing! Thank you for testing!

Revo wrote
Would be nice to be able to plug the light phaser on port controller 2.

I should be able to do this. But why port 2? Is that where the Light Phaser is normally connected for official games? (Please forgive my ignorance - I've never used one before)

SteveProXNA wrote
Awesome! I re-entered + increased my vote :) BTW: did you build this demo using the devkitSMS?
If so then would you pls be able to share your code or Github repo etc? Thanks

Thanks! Yes, I used devkitSMS. I'm not sure if releasing this code is a good idea.. The code quality is low, this was just an experiment. If something does not seem to make sense well... it probably does not. Don't look too hard for a reason why I did this or that!

That said, here is the repo: https://github.com/raphnet/sms_etch
  View user's profile Send private message Visit poster's website
  • Joined: 25 Jul 2007
  • Posts: 716
  • Location: Melbourne, Australia
Reply with quote
Post Posted: Wed Apr 07, 2021 2:02 am
Revo wrote
Working fine thank you!




Would be nice to be able to plug the light phaser on port controller 2.


This has me curious, could it be possible to build a light pen and draw directly on the screen?
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Wed Apr 07, 2021 7:15 am
I think it's totally doable
  View user's profile Send private message
Revo
  • Guest
Reply with quote
Post Posted: Wed Apr 07, 2021 7:49 am
raphnet wrote
I should be able to do this. But why port 2? Is that where the Light Phaser is normally connected for official games? (Please forgive my ignorance - I've never used one before)


For example if you boot SMS A Sketch from an everdrive you need controller 1 to select/boot the game, then you need to unplug the controller, plug the Light Phaser...
 
  • Joined: 12 Oct 2015
  • Posts: 183
  • Location: Ireland
Reply with quote
Post Posted: Wed Apr 07, 2021 9:52 am
raphnet wrote
Thanks! Yes, I used devkitSMS. I'm not sure if releasing this code is a good idea.. The code quality is low, this was just an experiment. If something does not seem to make sense well... it probably does not. Don't look too hard for a reason why I did this or that! That said, here is the repo: https://github.com/raphnet/sms_etch


Thanks a lot for sharing raphnet! It's great that you managed to get the light gun working and on real hardware using the devkitSMS which is something that I have been struggling with... I think somebody suggested that the light gun could be a useful addition to 3D City so will check out now thanks.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Wed Apr 07, 2021 12:01 pm
I've some code for that, if you're interested :-)
  View user's profile Send private message
  • Joined: 25 Dec 2005
  • Posts: 607
  • Location: São Paulo - Brazil
Reply with quote
Post Posted: Wed Apr 07, 2021 3:30 pm
Really awesome entry. Graded 10 for sure!
  View user's profile Send private message
  • Joined: 12 Oct 2015
  • Posts: 183
  • Location: Ireland
Reply with quote
Post Posted: Wed Apr 07, 2021 3:43 pm
kusfo wrote
I've some code for that, if you're interested :-)

For sure - would this be from one of your Github repos? Thanks kusfo
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 879
  • Location: Spain
Reply with quote
Post Posted: Thu Apr 08, 2021 10:06 am
I don't have it on a repo, but maybe I can upload an example to github, just in case
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!