~ubuntu-branches/debian/experimental/mednafen/experimental

« back to all changes in this revision

Viewing changes to src/sms/vdp.cpp

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-01-31 07:21:35 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120131072135-es3dj12y00xcnrsk
Tags: 0.9.19-1
* New upstream WIP version.
* Update copyright information.
* Refresh use-system-tremor.patch and remove psx-big-endian-only.patch.
* Add spelling-fixes.patch based on Lintian's recommendations.
* Build-depend on debhelper 9 or later and remove corresponding Lintian
  override.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
/* Initialize VDP emulation */
29
 
void vdp_init(void)
 
29
void vdp_init(bool want_quirk)
30
30
{
31
31
 memset(&vdp, 0, sizeof(vdp_t));
32
32
 
33
33
 vdp.lines_per_frame = (sms.display == DISPLAY_NTSC) ? 262 : 313;
 
34
 vdp.quirk_disabled = !want_quirk;
34
35
 
35
36
 vdp_reset();
36
37
}
68
69
 vdp.mode = 0;
69
70
 vdp.vint_pending = 0;
70
71
 vdp.hint_pending = 0;
 
72
 vdp.hc_latch = 0;
71
73
 vdp.cram_latch = 0;
72
74
 vdp.bd = 0;
73
75
}
74
76
 
 
77
void vdp_hclatch(void)
 
78
{
 
79
 unsigned int pixel_pos = ((sms.timestamp % CYCLES_PER_LINE) * 3) >> 1;
 
80
 
 
81
 if(pixel_pos >= 0x128)
 
82
  pixel_pos += 0xAA;
 
83
 
 
84
 vdp.hc_latch = pixel_pos >> 1;
 
85
}
75
86
 
76
87
void viewport_check(void)
77
88
{
289
300
 
290
301
uint8 vdp_counter_r(int offset)
291
302
{
292
 
    int pixel_pos;
293
 
 
294
303
    switch(offset & 1)
295
304
    {
296
305
        case 0: /* V Counter */
297
306
            return vc_table[sms.display][vdp.extended][vdp.line & 0x1FF];
298
307
 
299
308
        case 1: /* H Counter */
300
 
            //pixel_pos = (((z80_get_elapsed_cycles() % CYCLES_PER_LINE) / 4) * 3) * 2;
301
 
            // FIXME
302
 
            // FIXME
303
 
            pixel_pos = (((sms.timestamp % CYCLES_PER_LINE) / 4) * 3) * 2;
304
 
            return hc_table[0][(pixel_pos >> 1) & 0x01FF];
 
309
                vdp_hclatch();  // FIXME, call from pio.cpp under right conditions instead.
 
310
            return vdp.hc_latch;
305
311
    }
306
312
 
307
313
    /* Just to please the compiler */
537
543
 
538
544
    for(vdp.line = 0; vdp.line < vdp.lines_per_frame;)
539
545
    {
540
 
        int moohack = 228;
 
546
        int moohack = CYCLES_PER_LINE;
541
547
 
542
548
        ExecuteCycles(228 - 32);
543
549
        moohack -= 228 - 32;
619
625
  SFVARN(vdp.mode, "mode"),
620
626
  SFVARN(vdp.vint_pending, "vint_pending"),
621
627
  SFVARN(vdp.hint_pending, "hint_pending"),
 
628
  SFVARN(vdp.hc_latch, "hc_latch"),
622
629
  SFVARN(vdp.cram_latch, "cram_latch"),
623
630
  SFVARN(vdp.bd, "bd"),
624
631