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 - Can't get VBlanking to work

Reply to topic
Author Message
  • Joined: 21 Oct 2010
  • Posts: 47
  • Location: Space
Reply with quote
Can't get VBlanking to work
Post Posted: Wed Mar 16, 2016 1:27 pm
Last edited by Klangfarbe on Wed Mar 16, 2016 8:52 pm; edited 1 time in total
Hello.
Before i start: If You answer, please do not just showoff Your skill, PLEASE explain.
I followed Maxim's Hello World tutorial, and now i want to inject PSGLib into my little ROM. I used BMP2Tile to put a (hand-) converted Harvest Moon GB screen into the ROM instead of the Hello World text. Everything except music works now. I can't get Maxim's VBlanking tutorial ( http://www.smspower.org/maxim/HowToProgram/UsingTheVBlankForTiming ) to work, no matter what i try.
I read about someone else having similiar problems, with the tune being static and all. I could not fix my problem with the answers in that respective thread.
I will upload both the .asm file and the .psg one. The cover is made by myself and i'd be happy if noone will use it outside of here.
I would be very happy if someone pointed out the errors i have (probably) done, and maybe if someone would put the VBlank thing (plus call PSGFrame) into it so i can see it and memorize it and understand it. At this very moment my mind has gone tilt and i honestly can't understand it anymore. I guess the actual solution will be pretty easy, lol =)
Thanks in advance!
(the .asm file lacks any code regarding VBlanking now, and also the call PSGFrame isn't there for now)
PS: how about changing .psg files to be allowed ~v~..
link to psg file:
http://puu.sh/nIAfm/7697a5d9bf.psg -> save as

edit:
removed the swearing lol,
Hello World.asm (15.63 KB)
a

  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 331
Reply with quote
Post Posted: Wed Mar 16, 2016 2:47 pm
Interpreting the french as passion :) Is attached file what you were after?

- added some defines for code clarity sake.
- added interrupt handler (from maxims tutorial) and pointed it at PSGFrame.
- fixed up code at .org 0000 (now flows to your main body of code).
- moved PSGlib set up more appropriate place (following vdp set up).
- added code to enable vblanks
- enabled interrupts before loop.

Things to remember about vblank interrupts.
- Need to be set up on VDP registers for interrupts (register 1, see Charles VDP Doc http://www.smspower.org/uploads/Development/msvdp-20021112.txt). Inserted code...

; Turn on frame interrupts
    ld a, SCREEN_VBlankInteruptsOn
    out (VDP_ControlPort),a         
    ld a, VDP_R01
    out (VDP_ControlPort),a



- need to enable interrupts. Inserted code...

ei



- need to have interrupt handler code at org $38 on bank 0 (I copied this for you from maxims tutorial). Inserted code...

;==============================================================
; Interrupt Handler (code from Maxim tutorial)
;==============================================================
.org $38
.section "Interrupt handler" force
  push af
    in a,(VDPStatus) ; satisfy interrupt
    push hl
      ld hl, PSGFrame
      call CallHL
    pop hl
  pop af
  ei
  reti

CallHL:
  jp (hl)
.ends


Caught me before sleep. If you have questions ask away, will answer if someone does not beat me to it.
Klangfarbe.zip (8.47 KB)

  View user's profile Send private message
  • Joined: 21 Oct 2010
  • Posts: 47
  • Location: Space
Reply with quote
Post Posted: Wed Mar 16, 2016 8:48 pm
Woah! thank You! I put all the things at the wrong place, no wonder it didn't work xD
Now i only have one question left - how can i make it all play correct @ 50HZ? VGM2PSG seems to have an issue(?) and always processes my PAL .vgm as NTSC.. i work with XPMCK MML and i defined #PAL so it should work actually.. i looked at the C source of VGM2PSG but it's too complicated for me since i have almost 0 experience in C =X
Regarding the swearing bits, yes, that is passion definitely haha, i love the SMS and it's the reason why i'm doing this to myself and why i get upset over things =)) i really underestimated learning assembly!

edit:
i 'cheated' for now and added 1.2x the BPM to the tune so that it will play on normal speed if recognized as NTSC lololo, but still i would like to know the proper way for the future! =))
  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 331
Reply with quote
Post Posted: Wed Mar 16, 2016 11:39 pm
I ran in to similar issues, see thread http://www.smspower.org/forums/15822-NTSCToPALTimings.

KiddEd has tools to switch between pal and ntsc however i am not sure if part of the official release. Pretty sure it is if tune is less than 16k.

I also used the trick you used as a stop gap. Works fine though some emulators get a little confused.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Thu Mar 17, 2016 9:50 am
PSGFrame destroys registers AF,HL,BC so you should save them all in your interrupt handler, or you'll have bugs in your code sooner or later.

Also, I'm curious about your issues with vgm2psg... if it's not recognizing your VGMs the correct way:
- ensure you're using the latest version
- done that, if it still fails at identifying, please attach here / send me the offending VGM and as much info about it as possible (VGM version, software you're using to make it...) so that I can fix the converter.
  View user's profile Send private message Visit poster's website
  • Joined: 21 Oct 2010
  • Posts: 47
  • Location: Space
Reply with quote
Post Posted: Fri Apr 01, 2016 3:01 pm
OK i will have a look into it later, sverx! psidum, how are You doing it with KiddEd? i downloaded it but couldn't find out myself until now heheh. i guess it's something about the import/export of VGMs tho~
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!