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 - SMS VDP Tester

Reply to topic Goto page 1, 2  Next
Author Message
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed Feb 27, 2008 9:28 pm
The values should be between 0xE9 -> 0xFF & 0x00 -> 0x93 (or how ever you want to count).
Every third value is repeated once. On my 2 SMS they are like this:
0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06...
Though on my MD I don get a definitive sequence, it repeates both 0x00, 0x01 & 0x02 depending on how it feels when I turn it on.
I will try to fix up the test later to account for this.
  View user's profile Send private message Visit poster's website
Guest
  • Guest
Reply with quote
Post Posted: Thu Feb 28, 2008 4:31 am
Isn't the horizontal counter only used for the light gun and nothing else ?
 
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Thu Feb 28, 2008 7:31 am
Nope, I'm using it right now in my test program as you can see :P
  View user's profile Send private message Visit poster's website
  • Joined: 23 Feb 2007
  • Posts: 18
Reply with quote
Post Posted: Thu Feb 28, 2008 10:26 am
FluBBa wrote
The values should be between 0xE9 -> 0xFF & 0x00 -> 0x93 (or how ever you want to count).
Every third value is repeated once. On my 2 SMS they are like this:
0x00, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06...
Though on my MD I don get a definitive sequence, it repeates both 0x00, 0x01 & 0x02 depending on how it feels when I turn it on.
I will try to fix up the test later to account for this.


thanks, this was definitely a mistake in the table I used, I fixed this (it was even described in GG docs and it's the same for genesis in h32 mode)

About the repetitive value,doesn't it depend on read timings ?

btw, I always thought that hc latch could only work with external peripheral driving TH, that is when TH is set to input only (on the genesis for example, it seems that you can not trigger INT2 by setting TH to output and writing 0 then 1 into TH bit)
  View user's profile Send private message
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Thu Feb 28, 2008 12:25 pm
Christophe wrote
About the repetitive value,doesn't it depend on read timings ?

It depends on the syncronisation between the VDP clock and the CPU clock.
Christophe wrote
btw, I always thought that hc latch could only work with external peripheral driving TH, that is when TH is set to input only (on the genesis for example, it seems that you can not trigger INT2 by setting TH to output and writing 0 then 1 into TH bit)

I don't know how the MD acts in MD mode as I don't have a flashcart for the MD, the HCount latch works just fine in SMS mode (except that the repeating values are not the same all the time).
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Thu Mar 27, 2008 4:19 pm
Added 2 new test for line interrupt and vblank interrupt, plus some very preliminary mode5 palette test.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Sat Apr 05, 2008 7:06 pm
I don't quite follow how you measure the HCount values, especially the offsets (eg your "0xE9 -> 0xFF & 0x00 -> 0x93" statement - why do you start at $E9?)

When the H counter is latched, my current logic simply takes the number of CPU cycles that have executed since the start of the current scanline, multiplies by 342 then divides by 228. This fails the test!

I've attached two screenshots - the first is generated when I take the main SMS test, the second when I take the HCount timing test. I haven't found any emulators that pass the test, so have nothing to compare them against!

This is the last test I'm failing, so am naturally quite eager to correct my bugs!
HCountMainTest.png (1.85 KB)
HCount values -- SMS test
HCountMainTest.png
HCountTimingTest.png (1.76 KB)
HCount values -- timing test
HCountTimingTest.png

  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Sat Apr 05, 2008 9:07 pm
Are you sure you're not dividing first and then multiply? (use paranthesis)
Even if you had the wrong numbers in your calculation you shouldn't end up with the same number 13 times =)

0xE9 is -23, that's ~46 vdp clocks before the screen starts, 0 is on pixel 0.
You also can use SMSAdvance on Visualboy Advance to see what the values should be.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Sat Apr 05, 2008 10:21 pm
FluBBa wrote
Are you sure you're not dividing first and then multiply? (use paranthesis)
Yes, the exact code is as follows:

/// <summary>
/// Latches the value of the horizontal counter.
/// </summary>
public void LatchHorizontalCounter() {
   int ExecutedCycles = this.Emulator.TotalExecutedCycles - this.CpuCyclesAtStartOfScanline;
   int PixelsDrawn = (ExecutedCycles * 342) / this.CpuCyclesPerScanline;
   this.HorizontalCounter = (byte)(PixelsDrawn / 2);
}
(I did forget to mention that I divided the number of pixels drawn by two).

I'm not quite sure how your test works, so I'm also not quite sure where I'm going wrong. If I rig LatchHorizontalCounter to simply increment HorizontalCounter by one (or any other number) each time it's called, the test results show a smoothly incrementing value to reflect that (however, for such a test to work, you'd need to poll the counter in < 1 CPU cycle, which isn't going to happen). If I just return ExecutedCycles directly (a value which changes wildly each call) I get similar results to the previous screenshots - long runs of identical numbers.

Could it be because scanlines aren't exactly 228 clock cycles long? On average they are, but some are a little longer (and some a little shorter) as not all sequences of instructions will fit into the 228 clock cycle designation.

Thank you very much for your patience, but I'm absolutely stumped here!

EDIT: My assumption - that scanlines aren't exactly 228 cycles long - seems to be vaguely correct. Rather than use the total number of CPU cycles that have been executed to calculate the offset from the start of the current scanline, I use a secondary counter that increments in fixed 228 increments and calculate the pixel offset based on that. I still get the wrong values, but at least they're only out in so far as they increment in the sequence 0, 0, 1, 2, 3, 3, 4, 5, 6, 6, ...
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Sun Apr 06, 2008 10:06 am
My calculation is something like this:

HCount = (590 - (scanLineCycle*3))/4;

Where scanLineCount should be between 0 & 227 (228 cycles).
  View user's profile Send private message Visit poster's website
  • Joined: 15 Dec 2006
  • Posts: 107
  • Location: UK
Reply with quote
Post Posted: Wed May 14, 2008 12:39 pm
Nice utility. The latest mobile version of JavaGear I have in the works passes the first screen of tests no problem.

Obviously on a mobile based emulator there is still a need to ensure speed is pretty good, and not to add unnecessary complexity.

With the line interrupt test (last test screen 2), it currently fails as both frame int and line int are set simultaneously, at the very last stage of the test. Can anyone recommend a lightweight way of implementing the correct behaviour?
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed May 14, 2008 7:53 pm
dj_yt wrote
Obviously on a mobile based emulator there is still a need to ensure speed is pretty good, and not to add unnecessary complexity.

I guess you haven't worked with a 16MHz ARM machine ;)
If you are talking about the HCounter I don't think you should put too much effort into that.
The frame interrupt is taken at the begining of line 0xC1 (193), the line interrupt happens between line 0x00 and 0xC0 (0 to 192) (Bock take note).
  View user's profile Send private message Visit poster's website
  • Joined: 15 Dec 2006
  • Posts: 107
  • Location: UK
Reply with quote
Post Posted: Wed May 14, 2008 9:44 pm
Trust me - the performance you get out of some Java phones when emulating a CPU, is probably the equivalent of a 16Mhz ARM processor running asm emulation. :)

Thanks for the clarification on the frame interrupt. I was setting the frame interrupt flag on line 192 and then actually allowing the interrupt to be triggered from line 193. Correcting this to the way you describe fixed the text.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Feb 2007
  • Posts: 18
Reply with quote
Post Posted: Tue May 20, 2008 9:45 am
from the WIKI:
Quote
The latter is a special case - the system hardware is designed so that the HCounter is automatically latched when either controller's TH line is active (0), and cannot be freely read.


your test is waiting for HC to change on a TH 0->1 transition. Emulating the contrary (like described in Wiki and docs) makes the test failed
so, who is right ?
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 15641
  • Location: London
Reply with quote
Post Posted: Tue May 20, 2008 10:13 am
The wiki may be wrong. I didn't confirm the details on hardware, just based on my own understanding of how things work and the official docs.
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Tue May 20, 2008 12:04 pm
As said before, the tests have been run succesfully on my 3 hardware configurations, I suppose there can be differences (maybe the Japanese SMS?).
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Thu Feb 26, 2009 9:36 pm
Updated the VDP tester, lots of timing and sprite tests.
  View user's profile Send private message Visit poster's website
Simon82_
  • Guest
Reply with quote
Post Posted: Fri Feb 27, 2009 12:58 pm
FluBBa wrote
Updated the VDP tester, lots of timing and sprite tests.


I cannot find an emulator that run it flawless...
 
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Wed Aug 12, 2009 11:03 pm
Would you mind explaining what "VCounter chg time" and the straight column are testing for?
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed Aug 12, 2009 11:50 pm
"VCounter chg time" measures/tests at what (HCount) time the scanline register (VCounter) changes.
The straight column tests at what (HCount) time HScroll value is latched.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Thu Aug 13, 2009 12:43 am
Thanks. :-)

When latching HCount, I calculate the value based on the total number of CPU cycles executed since the beginning of the scanline, divided by the number of cycles per scanline, multiplied by 342, then divided by 2. Does this sound right?

One problem I am aware of is that I count the total number of CPU cycles executed before outputting a value to a port, when in reality there should be a number of clock cycles before and after the output. I fudge the HCount values by subtracting eight before dividing by two, but in reality there would be a number of cycles before and after the output - how is that usually measured (do you have a reference)?

Edit: Sorry about that, I forgot that .zip files can contain other files (in this case, documentation) when it came to SMS ROMs :-$ I should learn to read first!
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Thu Aug 13, 2009 11:36 pm
Some comments on the version posted on the 26th February 2009, running on a real Game Gear in SMS mode:
  • When starting the screen blanks, then displays garbled nonsense for a second or so, then goes to the menu. Is this right?
  • HCounter correct: Error.
  • VCounter chg time: Error.
  • Frame IRQ HCount: Error.
  • VINT flag HCount: Error.
  • Spr col correct HC: Error.
  • Spr ovr correct HC: Error.
  • Column should be straight: It isn't (one row just below the centre is offset to just right of the centre).
  • HCounter Values: 27 28 29 2A 2A 2B 2C 2D 2D 2E ...
In Game Gear mode anything dealing with HCount is completely wrong ("HC change on TH 0->1" fails for starters, I guess that the hardware is disabled, with no light gun Game Gear games?) The HCounter values are reported as 63 in all cases.

Somewhat interestingly the errors match up identically with the errors in my emulator, and I was hoping to fix these by comparing my results to the ones from the hardware - so you could say I passed with flying colours. :-)
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Fri Aug 14, 2009 9:05 am
Do you get consistent repeating numbers for the HCount values?
You wrote that it had repeating numbers for 2A & 2D, on a SMS it should have repeating numbers for 26, 29, 2C and so on.
Can you see that pattern matches for all numbers on the GG or is it hard to see on the blurry screen ? ;)
Also I would like to know the patterns/numbers for when the scanline wraps (eg ~93 - ~E9).
Hopefully I can get hold of a GG and MasterGear adapter so I can test all of the stuff myself but that might be a while before it happens.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Fri Aug 14, 2009 10:28 am
The wrap occurs at 93->E0, but you'll have to wait for me to modify the program to use a clearer font and white-on-black before I can start trying to search for patterns in the HCount values. It's very difficult to read the results on the Game Gear screen, yes. ;-)
  View user's profile Send private message Visit poster's website
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Mon Aug 17, 2009 2:39 pm
benryves wrote
When latching HCount, I calculate the value based on the total number of CPU cycles executed since the beginning of the scanline, divided by the number of cycles per scanline, multiplied by 342, then divided by 2. Does this sound right?


You must also remember that a scanline isn't exactly broken up how most people think of it. The exact relationship of the cycle count (and even when latching occurs) isn't quite known yet. Sega documentation states the first visible area of the screen is drawn at hlatch of $08. I hope to verify this in a month or two.

The way Flubba (and lightguns) latches the count also might be delayed by a few cycles, it's hard to verify that though.

benryves wrote
One problem I am aware of is that I count the total number of CPU cycles executed before outputting a value to a port, when in reality there should be a number of clock cycles before and after the output. I fudge the HCount values by subtracting eight before dividing by two, but in reality there would be a number of cycles before and after the output - how is that usually measured (do you have a reference)?


In most Z80 emulators when an IO occurs you are looking at the cycles executed PRIOR to the IO instruction being executed. In reality it's a few cycles later than that when the write/read actually happens. The other issue on top of that is then when the receiving device "accepts the write/read".

Also if you are using a MAME Z80 or something along these lines there are a few timing errors in it, and also issues with IRQs taking much longer than they should. You should make sure the prefix instructions return instead of executing in large blocks. I still don't think it's possible to pass all of Flubbas test without a cycle accurate Z80 emulator though?
  View user's profile Send private message Visit poster's website
  • Joined: 12 Apr 2005
  • Posts: 391
  • Location: London, United Kingdom
Reply with quote
Post Posted: Mon Aug 17, 2009 2:52 pm
PoorAussie wrote
In most Z80 emulators when an IO occurs you are looking at the cycles executed PRIOR to the IO instruction being executed. In reality it's a few cycles later than that when the write/read actually happens. The other issue on top of that is then when the receiving device "accepts the write/read".

I'll try swapping the order over in my code then, if only to be consistent with other emulators. :-)
Quote
Also if you are using a MAME Z80 or something along these lines there are a few timing errors in it, and also issues with IRQs taking much longer than they should. You should make sure the prefix instructions return instead of executing in large blocks. I still don't think it's possible to pass all of Flubbas test without a cycle accurate Z80 emulator though?

I wrote the Z80 emulator myself, and any "repeating" instruction (LDIR, OTIR, HALT etc) shunts PC back to its original position and returns after each execution rather than repeating, so that shouldn't be an issue. There have been timing errors in the past (there are some popular documents that claim that a failed JP c takes 1 clock cycle!) so I wouldn't rule those out.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Thu Aug 20, 2009 9:03 am
Quote
I still don't think it's possible to pass all of Flubbas test without a cycle accurate Z80 emulator though?


About that, I don't think a complete cycle-accurate Z80 core is necessary for SMS emulation since all hardware devices that need to synchronize with the Z80 (VDP, PSG and I/O chip) and therefore need to handle Z80 accesses at the cycle level, are all mapped to I/O memory. This would limit cycle accuracy to the few INx/OUTx instructions, right ?

And since interrupts can only be accepted between instructions, it should be perfectly accurate to handle them at the instruction level, as long as you trigger IRQ at the correct cycle.

The MAME core for example, is already doing that (checking IRQ before each instruction) and is also adjusting the Z80 cycle count BEFORE actually having executed the instruction: with that in mind, all that you need to modify are the INI/IND/INIR/INDR instructions, by only adding the last M-Cycle AFTER the I/O port has been read.


Quote

Also if you are using a MAME Z80 or something along these lines there are a few timing errors in it, and also issues with IRQs taking much longer than they should.


Could you please elaborate a bit more about these errors ? I know that, in the last version, 2 instructions timings have been fixed ($26 and $2E with $DD or $FD prefix) and the IM0 handling has been modified (now 0xFF is always read from the bus). Did you catched other errors ?

Quote

You should make sure the prefix instructions return instead of executing in large blocks


you are only talking about block transfer(LDIR,CPIR) and I/O (INIR,OTIR,...) instructions, right ?
Because, according to the documentation, interrupts cannot be accepted during instruction execution, including the prefixed one ($DD $DD $DD $26 ... for example, can not be interrupted).
  View user's profile Send private message
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Thu Aug 20, 2009 9:32 am
Eke wrote
About that, I don't think a complete cycle-accurate Z80 core is necessary for SMS emulation since all hardware devices that need to synchronize with the Z80 (VDP, PSG and I/O chip) and therefore need to handle Z80 accesses at the cycle level, are all mapped to I/O memory. This would limit cycle accuracy to the few INx/OUTx instructions, right ?

And since interrupts can only be accepted between instructions, it should be perfectly accurate to handle them at the instruction level, as long as you trigger IRQ at the correct cycle.


Kinda. :) For some reason a few months ago I had my interrupt reading code at the first cycle of each instruction but it actually happens on the last cycle of the instruction. It was making Flubbas VDP test read a bit incorrect for the interrupts.

So in theory a game could exploit this weakness in an instruction accurate only emulator, since they read the interrupt on the first cycle usually. How necessary is it "with the currenty software library"? Hard to say.

For the SMS, complete cycle accuracy isn't exactly going to bring that much enjoyment, as you said you could concentrate on the in/out and that would do make most of the leap for the SMS when it comes to accuracy (for existing devices anyhow).

BUSREQ and things of this nature require a lot more accuracy, which in theory SMS cartridges could use.

Eke wrote
The MAME core for example, is already doing that (checking IRQ before each instruction) and is also adjusting the Z80 cycle count BEFORE actually having executed the instruction: with that in mind, all that you need to modify are the INI/IND/INIR/INDR instructions, by only adding the last M-Cycle AFTER the I/O port has been read.

Could you please elaborate a bit more about these errors ? I know that, in the last version, 2 instructions timings have been fixed ($26 and $2E with $DD or $FD prefix) and the IM0 handling has been modified (now 0xFF is always read from the bus). Did you catched other errors ?


It was a while ago I looked at MAME, a friend of mine wrote a cycle Z80 emulator and reported those fixes to MAME (after I pointed them out, he has an affinity with MAME I do not share). There are other timing issues as I remember more than 2, I would have to look at the MAME Z80 again to find them and I can't really be bothered to do it. If you check the Z80 manual, and all the undocumented instruction documents, and then understand how the Z80 works at the cycle level you should be able to find them.

Eke wrote
you are only talking about block transfer(LDIR,CPIR) and I/O (INIR,OTIR,...) instructions, right ?
Because, according to the documentation, interrupts cannot be accepted during instruction execution, including the prefixed one ($DD $DD $DD $26 ... for example, can not be interrupted).


It's one thing I need to test at some time the interrupt relationship with the prefix instructions. I would tend to believe that they would be read as "separate instructions" which simply set flags for the Z80 upon further execution. You could verify this with the M1 pin I guess. Where did you read that they could not be interrupted?
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Thu Aug 20, 2009 10:35 am
Quote

Kinda. :) For some reason a few months ago I had my interrupt reading code at the first cycle of each instruction but it actually happens on the last cycle of the instruction. It was making Flubbas VDP test read a bit incorrect for the interrupts.


hmm, I see what you mean.. can't this be corrected by simply checking for interrupts AFTER instruction execution ? Also,since interrupts on the SMS occurs at very predictable time, you could synchronize your CPU execution with the VDP by making interrupt occurence (first VINT then HINT, or is it the contrary ?) as the first "event" of line execution...

However, it still leave the problem of interrupts being triggered after a VDP register write but I have no idea what the timing should be in that case (does the VDP triggers IRQ line *immediately* ? I know one mega drive game that requires one 68k instruction latency between the moment interrupt is enabled through teh VDP register and the moment the VDP is triggering the IRQ6 line)

Quote

For the SMS, complete cycle accuracy isn't exactly going to bring that much enjoyment, as you said you could concentrate on the in/out and that would do make most of the leap for the SMS when it comes to accuracy (for existing devices anyhow).

BUSREQ and things of this nature require a lot more accuracy, which in theory SMS cartridges could use.


yeah, but then comes the use of emulating something that could only be used by hardware that does not even exist.

for a mega drive emulator though, it would be necessary

Quote

It was a while ago I looked at MAME, a friend of mine wrote a cycle Z80 emulator and reported those fixes to MAME (after I pointed them out, he has an affinity with MAME I do not share). There are other timing issues as I remember more than 2, I would have to look at the MAME Z80 again to find them and I can't really be bothered to do it. If you check the Z80 manual, and all the undocumented instruction documents, and then understand how the Z80 works at the cycle level you should be able to find them.

yeah, I've started doing that... the Z80 instruction decoding and execution process is quite logical when you start thinking about it (just that variable Wait States are sometime automatically added for some instructions without apparent logic but some consistance between instructions of the same type).

anyway, about the MAME core, so far timings are correct and it's also pretty accurate regarding flags (they even recently added proper emulation of some BIT undocumented instructions, with the use of a MEMPTR register), which is not so surprising considering the amount and quality of work which has been put so far in this project.


Quote
Where did you read that they could not be interrupted?


from Sean Young's famous document (chapter 5.5):


Quote
And yes, for all instructions, including the prefixed ones, interrupts are never accepted during an instruction. Only after the tested instruction. Remember that block instructions simply re-execute themselves (by decreasing the PC with 2) so an interrupt is accepted after each iteration.

Another predictable test is this: at the \insert instruction to test" insert a large sequence of EI instructions. Of course, during execution of the EI instructions, no interrupts are accepted.

But now for the interesting stuff. ED or CB make up instructions, so interrupts are accepted after them. But DD and FD are prefixes, which only slightly affects the next opcode. If you test a large sequence of DDs or FDs, the same happens as with the EI instruction: no interrupts are accepted during the execution of these sequences.

This makes sense, if you think of DD and FD as a prefix which set the \use IX instead of HL" or \use IY instead of HL" °ag. If an interrupt was accepted after DD or FD, this flag information would be lost, and:
DD 21 00 00 LD IX,0
could be interpreted as a simple LD HL,0 if the interrupt was after the last DD.
Which never happens, so the implementation is correct. Although I haven't tested this, as I imagine the same holds for NMI interrupts.
  View user's profile Send private message
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Thu Aug 20, 2009 1:30 pm
Eke wrote
hmm, I see what you mean.. can't this be corrected by simply checking for interrupts AFTER instruction execution ? Also,since interrupts on the SMS occurs at very predictable time, you could synchronize your CPU execution with the VDP by making interrupt occurence (first VINT then HINT, or is it the contrary ?) as the first "event" of line execution...


The cpu samples the interrupt pin on the rising edge of the last cycle (ie before it executes last cycle). So sampling the interrupt pin after an instruction is one cycle late.

Eke wrote
yeah, but then comes the use of emulating something that could only be used by hardware that does not even exist.


Yep but then what is the point of going half way between a MAME Z80 and something like RC? MEKA "runs" all the existing SMS games with its core... ;)

One thing I didn't want to do for my own reasons, is to have to come back later and rewrite the CPU emulator, so the cycle accurate 6502 and Z80 I did are made to be used in any project, whether emulated or real. And I want to do genesis later and any addon SMS hardware people design.

Eke wrote
anyway, about the MAME core, so far timings are correct and it's also pretty accurate regarding flags (they even recently added proper emulation of some BIT undocumented instructions, with the use of a MEMPTR register), which is not so surprising considering the amount and quality of work which has been put so far in this project.


Oh so they've fixed all their issues? Good to hear. ;)

Quote
But now for the interesting stuff. ED or CB make up instructions, so interrupts are accepted after them. But DD and FD are prefixes, which only slightly affects the next opcode. If you test a large sequence of DDs or FDs, the same happens as with the EI instruction: no interrupts are accepted during the execution of these sequences.


I'd like to test it personally to verify because you never know for sure until you try yourself. It's also important for me to know the exact output of each of the Z80 pins for my goals and no one has documented this. I'd like to at one stage be able to use RC as a replacement for a real Z80.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Thu Aug 20, 2009 1:49 pm
Quote
The cpu samples the interrupt pin on the rising edge of the last cycle (ie before it executes last cycle). So sampling the interrupt pin after an instruction is one cycle late.


yes, I understand what you mean: you mean that in the case where the IRQ is triggered just after the last cycle, it is not supposed to be accepted until the NEXT instruction but here, it would be taken immediately, the result being one instruction less when exception processing starts.

But what I wanted to say was that since we knew that interrupts are triggered exactly each 342 cycles and that interrupts are only accepted between instructions, you could perfectly do something as simple as this on each line:

1) if required, VDP assert IRQ line
2) run 342 cycles (check for interrupts before each instruction)

Or would you mind explaining me what errors this could introduce ?


I mean, I know it's not perfectly accurate but anywxay, there is no way for you to know where the VDP exactly is (which line and which HCount) when the Z80 end its RESET process and starts executing instructions so even a cycle-accurate Z80 emulator is worthless as long as you didn't accurately initialized the synchronization, right ?
  View user's profile Send private message
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Thu Aug 20, 2009 2:15 pm
Eke wrote
yes, I understand what you mean: you mean that in the case where the IRQ is triggered just after the last cycle,


Or *during* the last cycle. The VDP runs 3 cycles per one Z80. If the VDP misses the rising edge of the last cycle then one more instruction should execute before IRQ. If you are sampling a cycle late it means you will take interrupts earlier than you should.

Eke wrote
it is not supposed to be accepted until the NEXT instruction but here, it would be taken immediately, the result being one instruction less when exception processing starts.


Right.

Eke wrote
But what I wanted to say was that since we knew that interrupts are triggered exactly each 342 cycles and that interrupts are only accepted between instructions, you could perfectly do something as simple as this on each line:


VDP runs at 684 cycles per scanline. You would need to perfectly count the cycles needed and then work out when you get close to the end whether or not you should take the interrupt, etc.

There are plenty of ways to optimize the need for a true cycle accurate core, I've done plenty of them. It is quite fun really, caching writes, catching up devices, plenty of different ways to optimize. Thing is though what is the point of doing all this? That tiny bit of speed you gain is offset by ungainly code and complication that will drive you insane after you put it away for a month.

Take a look at BlueMSX for an example, I haven't tested my VDP core against it for speed, but my codebase is 5 times smaller. If you take away the parts that have nothing to do with the SMS, it's only 3 times smaller. but my core also emulates the SMS VDP which it doesn't, so it's an interesting thing to wonder about.

An old NES emulator I worked on had cached writes and things of this nature to simulate cycle accuracy fairly well, but thankfully I don't have to touch that era again. ;)


Eke wrote
I mean, I know it's not perfectly accurate but anywxay, there is no way for you to know where the VDP exactly is (which line and which HCount) when the Z80 end its RESET process and starts executing instructions so even a cycle-accurate Z80 emulator is worthless as long as you didn't accurately initialized the synchronization, right ?


The BIOS takes away some of the "startup" issues since software can't really get an idea about what is before it thanks to the BIOS. It's one of those things we have to find out though, the startup synchronization in regards to the VDP. In regards to clock sync though, you just have to align the master clock to the devices correctly, it's fairly straight forward for the SMS since the devices all run off integer ratios unlike other systems.

In RetroCopy I have the VDP executed for 2 cycles before the first cycle of the Z80 and third of the VDP. It may be a bit different than this. You have to be careful to make sure when devices are running on the same "cycle" together that they can't see each others output either until the end.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Tue Aug 25, 2009 10:34 am
I finally managed to pass all test successfully with SMS Plus. The few changes required are listed below (no cycle accurate Z80 emulation though , cycle count is updated before processing the instruction).

The only thing that was *really* required was somehow limited cycle-accurate VDP execution, i.e each time you are writing a VDP register and reading the VDP status or VC registers, you have to check if the current cycle count did not moved to the next line...

If the current cycle count indicates we are already on the next line, I parse sprites and render the line immediately before updating the register (this makes xscroll latched correclty) or reading the status flag (this updates INT and OVR flags at the correct HC). A flag is obviously set to prevent rendering the same line twice.

Same goes for VC register, the current line is deducted from the current cycle count (z80_get_elapsed_cycles()/CYCLES_PER_LINE) instead of using the incrementing line counter.

About the COL flag, it is, as usual, set during the line rendering function (done once at the beginning of each line) but additional information provides the line and the HC value ((xpos >> 1) + 0x06) on which it occured. When the VDP status is read, the current HC and lines value are compared to return the real-time status of this flag.

The first event of the line is Horizontal interrupt and HC table starts at 0xF4.

Updated sourcecode should be available here soon for anyone interested ;-)
  View user's profile Send private message
  • Joined: 28 Sep 1999
  • Posts: 1200
Reply with quote
Post Posted: Tue Aug 25, 2009 3:18 pm
Eke wrote
I finally managed to pass all test successfully with SMS Plus.


Wow, I can't thank you enough for continuing development on SMS Plus and making it so accurate. This is thrilling news to me. :)
  View user's profile Send private message Visit poster's website
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Wed Aug 26, 2009 12:54 am
Nice work EKE, did you compare speed before and after the changes? Would be interesting to know.

Flubbas VDP test is a little loose with some of the timing stuff, I hope to make a new test soon once I get my dev system setup. Just to verify things and also something emulator authors can use to improve their emus. Anyhow, good work. :)
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed Aug 26, 2009 7:09 am
My SMS emu on the GBA clears all test (except all the sprite COL/OVR tests), so it doesn't have to be cpu taxing in any way.
@PoorAussie. Which tests are "a bit loose" now? I'm going to add some more things to the test right now so it would be nice to fix those tests as well.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Fri Aug 28, 2009 12:58 am
FluBBa wrote
@PoorAussie. Which tests are "a bit loose" now? I'm going to add some more things to the test right now so it would be nice to fix those tests as well.


Pretty much all of the timing ones, I've got about 4-8 VDP cycles difference in a lot of them before it breaks anything (this is with your previous test, I haven't used your newest one yet because you said you haven't verified it). I have to come up with ways to accurately get the timing information though in my own program, as you would know it's quite difficult. There are also other things to do with memory timing that your test doesn't cover that I want to do.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Wed Oct 21, 2009 8:08 am
PoorAussie wrote

Or *during* the last cycle. The VDP runs 3 cycles per one Z80. If the VDP misses the rising edge of the last cycle then one more instruction should execute before IRQ. If you are sampling a cycle late it means you will take interrupts earlier than you should.


I figured a simple and fast way to handle this... since interrupts are separated by a constant number of cycles (228 Z-Cycles or 684 M-Cycles), it's easy to check the current Z80 cycle count when interrupt is supposed to happen (at the start of the line for example). If it's exactly multiple of 228, it means the interrupts is triggered AFTER the instruction IRQ detection point and you have to execute one more single instruction before triggering interrupt... if it's 228+n (n>0), interrupt can be triggered immediately.


for (i=0;i<lines_per_frame;i++)
{
  /* check if Hint should be triggered on this line */
  if (xxxx)
  {
     if (count_z80%Z80_CYCLES_PER_LINE == 0)
        z80_execute(1);

     ....

     z80_set_interrupt();
   
 }


Same thing can be done for Vint, knowing the exact cycle where it occurs.

Quote
There are plenty of ways to optimize the need for a true cycle accurate core, I've done plenty of them. It is quite fun really, caching writes, catching up devices, plenty of different ways to optimize. Thing is though what is the point of doing all this? That tiny bit of speed you gain is offset by ungainly code and complication that will drive you insane after you put it away for a month.


Well, this is still way faster and more optimized than emulating Z80 and/or VDP with cycle granularity and does not add so much code complexity honestly... without losing any accuracy ;-)

And this is exactly my point: you can do a lot of things through different ways when you emulate something, but there is not a "better" or "more accurate" method as long as no program could tell the difference if you did things correctly (at least on a SMS).

Anyway, at the end, the only thing that should matter is the pleasure you have to code something in the way you like it, with complete understanding of what you are doing.

Some people would always prefer to limit themselves to what is really necessary and enjoy finding optimized way of doing things (and that doesn't mean necessarily sacrifying accuracy ou using infamous hacks), some others would always prefer to have full control on what they are emulating, at the lowest level possible, as near as the hardware as possible. Both approaches, which are sometime not so opposed, should be respected and not minimized because it's generally a motivated choice, not a matter of competence...
Btw, on that matter, I'd say the biggest challenge is not emulating hardware at the lowest timing level but to actually figure exactly what the hardware is doing and how it is doing it... thanks to charles,marat, MAME devs and all those generous contributers and opensource developpers, this makes the whole job damn easier by now :)

Quote

In regards to clock sync though, you just have to align the master clock to the devices correctly, it's fairly straight forward for the SMS since the devices all run off integer ratios unlike other systems.


well, that's not exactly true. Even when using Mclock as a base, there can be a shift between those 2 devices depending on when Z80 start its execution, for example, if it starts at Mcyc+(3*n)+1 or Mcyc+(3*n)+2, with Zclk=Mclk/3
To be exactly accurate, this should be taken in account (but again, I don't think this matters much since everything get synchronized with interrupt sooner or later)


Charles MacDonald wrote
Wow, I can't thank you enough for continuing development on SMS Plus and making it so accurate. This is thrilling news to me. :)


my pleasure :)
  View user's profile Send private message
  • Joined: 26 Aug 2008
  • Posts: 292
  • Location: Australia
Reply with quote
Post Posted: Wed Oct 21, 2009 12:55 pm
Eke wrote
Well, this is still way faster and more optimized than emulating Z80 and/or VDP with cycle granularity and does not add so much code complexity honestly... without losing any accuracy ;-)

And this is exactly my point: you can do a lot of things through different ways when you emulate something, but there is not a "better" or "more accurate" method as long as no program could tell the difference if you did things correctly (at least on a SMS).


I agree that if the SMS software can't tell the difference then in accuracy it doesn't matter how it's achieved at all. The means is irrelevant to the end. That said, I didn't want to design a Z80/VDP combo that was SMS only, and the Z80 SMSPLUS uses is inaccurate for busreq's and will need a complete rewrite to support it. SMS software can use busreq's (none does yet, though I will code a game which uses it eventually for DMA).

I have been criticized for calling this level of accuracy "perfect", because to me it is all that matters. If software is unable to detect a real system or emulator using every single possible method then it's perfection as far as I'm concerned. I actually go a step beyond this even just for my own reasons because I like developing software that is like real hardware. Nothing is going to intercept the VDP accessing it's VRAM for instance on the SMS but RetroCopy is right in there to do something with it if something did.

Eke wrote
Some people would always prefer to limit themselves to what is really necessary and enjoy finding optimized way of doing things (and that doesn't mean necessarily sacrifying accuracy ou using infamous hacks), some others would always prefer to have full control on what they are emulating, at the lowest level possible, as near as the hardware as possible. Both approaches, which are sometime not so opposed, should be respected and not minimized because it's generally a motivated choice, not a matter of competence...


Certainly. While I'm targeting not wanting to touch my cores again, writing them once and having them work until the end of time at cycle accuracy there will be cores which can be faster if they take certain knowledge about a system and optimize for it. Like the fact no existing SMS games use BUSREQ. Or the fact that a system has very regular interrupts or whatever. I'm completely for people doing that because it gives people with lesser computers the opportunity to use it at minimal sacrifice really. MEKA which is probably my favourite emulator is a perfect example of having near perfect compatibility at a very low cost, MEKA also did something different with it's interface compared to near everything else, it's obvious a lot of love was put into it which I respect.

BTW my Z80 emulator is "only" about 2-2.5 times slower than the MAME one, I used a technique I haven't seen in any other emulator that I talked about in another post. Most of the cost of cycle emulating the SMS comes with the VDP. My I7 is currently doing about 106 million emulated cycles per cycle per SMS core, at about 30 host cycles to one emulated cycle. This is enough to emulate 5 SMS's at cycle accuracy with high quality audio filtering and FM chip.

http://www.retrocopy.com/blog/52/emulator-benchmark.aspx

My original non cycle accurate (but high compat) SMS emulator I had in earlier versions of RetroCopy was getting about 2000FPS (3.2GHz core2), at cycle accuracy the same system is getting about 300FPS. So it's quite a bit slower overall.

Eke wrote
Btw, on that matter, I'd say the biggest challenge is not emulating hardware at the lowest timing level but to actually figure exactly what the hardware is doing and how it is doing it... thanks to charles,marat, MAME devs and all those generous contributers and opensource developpers, this makes the whole job damn easier by now :)


Yep, though it usually ends up being a question of access. There are plenty of talented guys on the internet who can code up wonderful things and crack lots of puzzles, but not all of them have access to logic analyzers and arcade boards.

Eke wrote
well, that's not exactly true. Even when using Mclock as a base, there can be a shift between those 2 devices depending on when Z80 start its execution, for example, if it starts at Mcyc+(3*n)+1 or Mcyc+(3*n)+2, with Zclk=Mclk/3
To be exactly accurate, this should be taken in account (but again, I don't think this matters much since everything get synchronized with interrupt sooner or later)


I meant the fact that all the devices run off integer ratios compared to each other. Other systems aren't so lucky. (Z80=PSG=FM=3VDP).

But yes it's an interesting thing to ponder about when it comes to how things start. Since there are some unknowns like the fact that the R register is different boot to boot on a real system by the time it gets to the game. I think it does matter though, RetroCopy can emulate it whatever it is but at the moment they do start at the same clock.
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed Nov 04, 2009 12:21 pm
I've tightened up the HInt & VInt HCount tests and tested it on my SMS1.
I thought I would write a test to find the background NameTable latch time but it looks like it's not latched at all and you can switch nametable mid-scanline.
  View user's profile Send private message Visit poster's website
  • Joined: 27 Oct 2009
  • Posts: 138
Reply with quote
Post Posted: Tue Nov 10, 2009 4:53 am
Thanks for the new test Flubba. I'm still interested in the sprite collisions happening in the border regions. Does your SMS1 have the original VDP or the second revision?
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Tue Nov 10, 2009 1:42 pm
In what way do you want to test it?
I already test collision in the side and top/bottom borders...
My SMS1 has the first VDP and my SMS2 has the newer VDP, problem is that I have hard time showing the RF signal from my SMS2...
  View user's profile Send private message Visit poster's website
  • Joined: 27 Oct 2009
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 11, 2009 5:30 am
FluBBa wrote
In what way do you want to test it?
I already test collision in the side and top/bottom borders...
My SMS1 has the first VDP and my SMS2 has the newer VDP, problem is that I have hard time showing the RF signal from my SMS2...


Well it's just interesting that sprite processing still happens in the border region. However the VDP must still process sprites during lines 0-191 even when the display is off because if it doesn't the first line of active display after enabling display again won't have sprites on it due to the "process sprites for next line" feature. So maybe they just have a "active display" which means draw and display tiles/sprites and an "off display" which means process sprites and memory.

From my tests though it looks like the sprite processing changes from the active display way of doing things to something else. Due to the 36 MCLK gap in active sprite processing where there are no CPU windows. This would break the 16 Z80 cycle "Sega limit" (when you add the VDP delay) for offscreen writes.

Have you ever checked where 'display off' is latched? I always thought it would be HC=0 but maybe it's HC=F4ish.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Wed Nov 11, 2009 12:46 pm
Quote
So maybe they just have a "active display" which means draw and display tiles/sprites and an "off display" which means process sprites and memory.


Most likely, what happen is that the display status only affects the output of the priority controller (background color is always picked but sprite collision is still checked as long as sprites are processed).

Sprites processing is more probaly timed with line events (Ypos during active line, Xpos/Name during HBlank), not with hdisplay status (hblank != display off or vblank), and controlled by the current vertical counter value.

Interestingly, on the Genesis, it has been noticed that forcing the display off during HBLANK will have effects on sprite processing (i.e some sprites data are going to be masked on the upcoming line) which would indicate that forcing the display OFF would also stop sprite processing, contrary to the blanked border areas (which seems obvious since you usually do that for "full" access to the CPU).

It might be interesting, on the SMS, to disable manually the display on line 192 and see if sprite collision still happen in the bottom/top border.


Quote
Have you ever checked where 'display off' is latched? I always thought it would be HC=0 but maybe it's HC=F4ish.


Are you sure it can't not be switched anytime during the line ?
On the Genesis VDP at least (i know it could be quite different but who knows), you can switch display off/on midline so the "display off" bit is apparently checked periodically during the line.
  View user's profile Send private message
  • Joined: 27 Oct 2009
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 11, 2009 1:24 pm
Eke wrote
Interestingly, on the Genesis, it has been noticed that forcing the display off during HBLANK will have effects on sprite processing (i.e some sprites data are going to be masked on the upcoming line) which would indicate that forcing the display OFF would also stop sprite processing, contrary to the blanked border areas (which seems obvious since you usually do that for "full" access to the CPU).

It might be interesting, on the SMS, to disable manually the display on line 192 and see if sprite collision still happen in the bottom/top border.

Are you sure it can't not be switched anytime during the line ?
On the Genesis VDP at least (i know it could be quite different but who knows), you can switch display off/on midline so the "display off" bit is apparently checked periodically during the line.


I'm fairly sure the display switch is latched rather than instant. I've emulated both and with it emulated as non latched the games which use it (impossible mission, cool spot, etc) don't display correctly or are otherwise glitchy. I don't remember those glitches on the real game.

So if it is latched it also means that it probably has a "table" if you want to call it that, of things to do for the line. I believe when it switches to the "off" table it must still do sprite processing in it, this simplifies things somewhat, line 312 or 261 can process sprites for line 0, sprites are still processed for the next line if it's toggled on/off for different lines, etc.

On the other hand if sprite processing was tweaked over the TMS, maybe an access window(s) was conveniently placed to not break the 16 Z80 cycle "limit". This way you could think of sprite processing as a layer which was always on regardless.

I know Charles has mentioned that you can disable the display in the horizontal border regions but I think this is more related to the Genesis than the SMS. You're not going to gain much on the SMS by doing it, the Z80/port simply can't feed much to it in that time frame.

I do find it weird though that collisions are set during the border regions. Possibly since the VDP is outputting border color and display is set to "on", the sprite display hardware is still being used but not shown. Is there a limit to where these are set? Flubba says "border region" but I would guess that applies to the full range of possible sprite Y values.
  View user's profile Send private message Visit poster's website
  • Joined: 27 Oct 2009
  • Posts: 138
Reply with quote
Post Posted: Wed Nov 18, 2009 3:35 pm
FluBBa wrote
I've tightened up the HInt & VInt HCount tests and tested it on my SMS1.
I thought I would write a test to find the background NameTable latch time but it looks like it's not latched at all and you can switch nametable mid-scanline.


Flubba does your emulator pass your test? I've noticed Fantastic Dizzy doesn't like sprite collisions to be set in the offscreen region, just wondering if you have tried running that game with that effect emulated.
  View user's profile Send private message Visit poster's website
  • Joined: 21 Jul 2005
  • Posts: 419
  • Location: GBG
Reply with quote
Post Posted: Wed Nov 18, 2009 5:43 pm
My emulator doesn't even attempt to do real sprite collision, so, no it doesn't pass many of the sprite tests.
Offscreen, is that in the top/bottom or the sideborders?
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Wed Nov 18, 2009 7:12 pm
My current version of SMS Plus passes all Flubba's tests (incl. sprites collision ones) and does not have any problem with that game.

However, I remember that having the sprite collision flag being set a little too early (or too late) in the line would produce some line flickering in the top status bar (also when the PAUSE button is pressed), this is very likely some inaccuracies with your pixel rendering/collision timing.
  View user's profile Send private message
  • Joined: 27 Oct 2009
  • Posts: 138
Reply with quote
Post Posted: Thu Nov 19, 2009 1:32 am
Eke wrote
My current version of SMS Plus passes all Flubba's tests (incl. sprites collision ones) and does not have any problem with that game.


Do you do sprite collision testing on every line of display? I noticed if you don't do any lines over 255 (256-311) Flubbas test still passes and the game now works, it seems a collision just before line 0 trips it up, but...

Eke wrote
However, I remember that having the sprite collision flag being set a little too early (or too late) in the line would produce some line flickering in the top status bar (also when the PAUSE button is pressed), this is very likely some inaccuracies with your pixel rendering/collision timing.


I am getting a little flicker on the second last line of the status bar so maybe you're right. It is wanting the "display off" to be latched about 30 MCLKs later than I currently do on some lines, it wants to turn off display for 2 lines to change the palette, on some frames it misses the right spot which is why the flicker occurs.

BTW does your smsplus pass the latest test from Flubba?
  View user's profile Send private message Visit poster's website
  • Joined: 06 Feb 2009
  • Posts: 112
  • Location: Toulouse, France
Reply with quote
Post Posted: Thu Nov 19, 2009 9:01 am
Quote
Do you do sprite collision testing on every line of display? I noticed if you don't do any lines over 255 (256-311) Flubbas test still passes and the game now works, it seems a collision just before line 0 trips it up, but...


I do sprite rendering (and collision test) on every line of active display, including vertical borders, that's 240 lines for NTSC and 288 lines for PAL (it should be 243 and 294 to be accurate but the Wii hardware limitations made it simpler to use those values and it doesn't really mattter anyway).
You are right that a collision occurs the line before 0 and the sprite collision flag is indeed used to switch the display OFF for a few lines. If your timings are not exactly what they are supposed to be, you indeed get line flickering (but I'm pretty sure that midline display switching is authorized so switching the display OFF anywhere during the HBLANK period should not be noticable).

Quote

BTW does your smsplus pass the latest test from Flubba?

yes it does ;-)

EDIT: actually it doesn't in PAL mode, I forgot to test that case: the offscreen sprite collision test indeed fails .
I guess it's because my border area is smaller than expected and the collision is programmed on a line outside the area I used. I should probably fix that by using more accurate overscan ranges and see if Fantastic Dizzy is affected ...
  View user's profile Send private message
Reply to topic Goto page 1, 2  Next



Back to the top of this page

Back to SMS Power!