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 2020] VU by sverx

Reply to topic

Rate this entry!

1 (Terrible) 6% 6%
2 0% 0%
3 0% 0%
4 12% 12%
5 6% 6%
6 18% 18%
7 25% 25%
8 18% 18%
9 6% 6%
10 (Excellent) 6% 6%
This poll has expired.
Author Message
  • Site Admin
  • Joined: 08 Jul 2001
  • Posts: 8649
  • Location: Paris, France
Reply with quote
[Coding competition 2020] VU by sverx
Post Posted: Tue Mar 24, 2020 8:08 pm
https://www.smspower.org/Homebrew/VU-SMS



Quote
(preamble) This has been quite rushed at the end as I didn't find enough time to improve it, but improvement is surely possible.

So here's *VU*: a standalone PSG player with VU meter display. Uses PSGlib of course. Source code included too.

The interesting part of the code is surely the routine that draws the 4 needles on screen using sprites.

This is done using the Integer Line Algorithm [ http://www.pyaray.com/articles/lines.htm ] to calculate which of 8 possible pre-loaded sprites should be used for each 8-pixel tall segment of the line, and the current implementation works only for those lines going from y0<y1 (going down on the screen) and with sharp angle only - that is, when the line will need at most one pixel per horizontal line.

As the current algorithm doesn't take into account on which lines the x position of the pixel should be incremented but only how many times we need to do that, the line isn't always drawn perfectly, but it's close enough after all.
Another limit is that the line might be drawn 'past' the destination point (x1,y1) as all the sprites contain line segments that are 8 pixels tall, so I had to mask that part of the line that I didn't want to show using black sprites strategically placed. Hey, it's a hack, of course!

From the VU perspective, for each channel the algorithm adds the volume of the last 17 samples (because 17*15=255 so I can always sum 17 values into a byte) and the resulting value is then shown by the needle (which has only 68 possible positions anyway, so it's scaled down of course).

17 samples at 60 fps take 283 ms which is almost 300 ms, the rise time expected by real VU meters, so the effect should look quite accurate too (18 samples would make that perfect, but would require ints instead of chars...)

Compiling the code creates a 16 KB ROM (complete with correct SEGA ROM signature). At this point, you can concatenate your PSG file to this ROM and send it to who you want (the PSG file limit is 32 KB).

on Windows: copy VU.sms+YourTune.psg YourROM.sms

on Linux: cat VU.SMS YourTune.psg > YourROM.SMS

VU.SMS is also provided, you don't need to recompile it if you're not planning any change.

Finally, two *GREAT* tunes ROM are included for your enjoyment:

- Z80HEARTONFIRE.SMS plays "Z80 HEART ON FIRE" by Polaria Poyon (used by permission)
- OUTRUNTUNE.SMS plays my favorite tune from OutRun (fair use, I guess...)

Also, for those using a Master EverDrive, the OS *should* load the file correctly from SD card even if the file size isn't rounded to any particular multiple/power size, as it's less than 64 KB, so you shouldn't need to pad your file. I can't test this myself at the moment, unfortunately.

I hope you'll enjoy this!
See you later :)

sverx


  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3823
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sat Mar 28, 2020 3:19 pm
first patch already (forgot to clear VRAM PNT!!! :( )

[VU 1.01 attached]
VU_1.01.zip (6.48 KB)
VU v.1.01

  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 877
Reply with quote
Post Posted: Sun Mar 29, 2020 12:45 pm
Very cool effect, and a beautiful way to play PSG tracks on the SMS.
  View user's profile Send private message
  • Joined: 12 Oct 2015
  • Posts: 194
  • Location: Ireland
Reply with quote
Post Posted: Fri Apr 03, 2020 8:23 pm
Cool idea! I'm on Windows but couldn't get this working initially; most likely user error but fortunately I had cygwin installed so the following works: cat VU.sms music_file.psg > output.sms Great job!
  View user's profile Send private message Visit poster's website
  • Joined: 18 Mar 2020
  • Posts: 33
Reply with quote
Post Posted: Fri Apr 10, 2020 1:13 pm
Great idea ! The effect is great, both useful and inspiring as usual with your tools / sdk! :)
I wasn't aware of the Integer Line Algorithm, thanks for the discovery too!
  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!