~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/vic20/vic-mem.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.1.7 upstream) (9.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090331003715-i5yisvcfv7mgz3eh
Tags: 2.1.dfsg-1
* New major upstream release (closes: #495937).
* Add desktop files (closes: #501181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Written by
5
5
 *  Ettore Perazzoli <ettore@comm2000.it>
6
6
 *  Andreas Matthies <andreas.matthies@gmx.net>
 
7
 *  Daniel Kahlin <daniel@kahlin.net>
7
8
 *
8
9
 * This file is part of VICE, the Versatile Commodore Emulator.
9
10
 * See README for copyright notice.
49
50
    vic.regs[addr] = value;
50
51
    VIC_DEBUG_REGISTER (("VIC: write $90%02X, value = $%02X.", addr, value));
51
52
 
52
 
    if (maincpu_clk >= vic.draw_clk)
 
53
    if (maincpu_clk >= vic.draw_clk) {
53
54
        vic_raster_draw_alarm_handler(maincpu_clk - vic.draw_clk, NULL);
 
55
    }
54
56
 
55
57
    switch (addr) {
56
58
      case 0:                     /* $9000  Screen X Location. */
66
68
            xstart = MIN((unsigned int)(value * 4), vic.screen_width);
67
69
 
68
70
            xstop = xstart + vic.text_cols * 8;
69
 
            if (xstop >= (int)vic.screen_width)
 
71
            if (xstop >= (int)vic.screen_width) {
70
72
                xstop = vic.screen_width - 1;
71
73
                /* FIXME: SCREEN-MIXUP not handled */
72
 
 
 
74
            }
73
75
 
74
76
            xstart *= VIC_PIXEL_WIDTH;
75
77
            xstop *= VIC_PIXEL_WIDTH;
267
269
 
268
270
      case 14:                    /* $900E  Auxiliary Colour, Master Volume. */
269
271
        /*
270
 
            changes of auxiliary color in cycle n is visible at pixel 4*(n-7)
 
272
            changes of auxiliary color in cycle n is visible at pixel 4*(n-7)+1
271
273
        */
272
274
        {
273
275
            static int old_aux_color = -1;
278
280
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk)),
279
281
                    &vic.auxiliary_color,
280
282
                    new_aux_color);
281
 
 
 
283
                /* old_mc_auxilary_color is used by vic-draw.c to handle the
 
284
                   one hires vic pixel lateness of change */
 
285
                raster_changes_foreground_add_int(&vic.raster,
 
286
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk+1)),
 
287
                    &vic.old_auxiliary_color,
 
288
                    new_aux_color);
282
289
 
283
290
                old_aux_color = new_aux_color;
284
291
            }
291
298
                                     Reverse Video. */
292
299
        /*
293
300
            changes of border/background in cycle n are visible at pixel
294
 
            4*(n-7),
295
 
            changes of reverse mode at pixel 4*(n-7)+3, which is quite ugly
296
 
            'cause we're using a character-based emulation :(FIXME)
 
301
            4*(n-7)+1, changes of reverse mode at pixel 4*(n-7)+3.
297
302
        */
298
303
        {
299
 
            static int old_video_mode = -1;
300
304
            static int old_background_color = -1;
301
305
            static int old_border_color = -1;
302
 
            int new_video_mode, new_background_color, new_border_color;
 
306
            static int old_reverse = -1;
 
307
            int new_background_color, new_border_color, new_reverse;
303
308
 
304
309
            new_background_color = value>>4;
305
310
            new_border_color = value & 0x7;
306
 
            new_video_mode = ((value & 0x8)
307
 
                             ? VIC_STANDARD_MODE : VIC_REVERSE_MODE);
 
311
            new_reverse = ((value & 0x8) ? 0 : 1);
308
312
 
309
313
            if (new_background_color != old_background_color) {
310
314
                raster_changes_background_add_int(&vic.raster,
311
 
                    VIC_RASTER_X(VIC_RASTER_CYCLE(maincpu_clk)),
 
315
                    VIC_RASTER_X(VIC_RASTER_CYCLE(maincpu_clk)) + VIC_PIXEL_WIDTH,
312
316
                    (int*)&vic.raster.background_color,
313
317
                    new_background_color);
314
318
 
317
321
 
318
322
            if (new_border_color != old_border_color) {
319
323
                raster_changes_border_add_int(&vic.raster,
320
 
                    VIC_RASTER_X(VIC_RASTER_CYCLE(maincpu_clk)),
 
324
                    VIC_RASTER_X(VIC_RASTER_CYCLE(maincpu_clk)) + VIC_PIXEL_WIDTH,
321
325
                    (int*)&vic.raster.border_color,
322
326
                    new_border_color);
323
327
 
327
331
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk)),
328
332
                    &vic.mc_border_color,
329
333
                    new_border_color);
330
 
 
 
334
            }
 
335
 
 
336
            if (new_reverse != old_reverse) {
 
337
 
 
338
                raster_changes_foreground_add_int(&vic.raster,
 
339
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk)),
 
340
                    &vic.reverse,
 
341
                    new_reverse);
 
342
            }
 
343
 
 
344
 
 
345
            if (new_border_color != old_border_color) {
 
346
                /* old_mc_border_color is used by vic-draw.c to handle the
 
347
                   one hires vic pixel lateness of change */
 
348
                raster_changes_foreground_add_int(&vic.raster,
 
349
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk+1)),
 
350
                    &vic.old_mc_border_color,
 
351
                    new_border_color);
331
352
 
332
353
                old_border_color = new_border_color;
333
354
            }
334
355
 
335
 
            if (new_video_mode != old_video_mode) {
 
356
            if (new_reverse != old_reverse) {
 
357
                /* old_reverse is used by vic-draw.c to handle the
 
358
                   3 hires vic pixels lateness of change */
336
359
                raster_changes_foreground_add_int(&vic.raster,
337
 
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk)),
338
 
                    &vic.raster.video_mode,
339
 
                    new_video_mode);
 
360
                    VIC_RASTER_CHAR(VIC_RASTER_CYCLE(maincpu_clk+1)),
 
361
                    &vic.old_reverse,
 
362
                    new_reverse);
340
363
 
341
 
                old_video_mode = new_video_mode;
 
364
                old_reverse = new_reverse;
342
365
            }
343
366
 
344
367
            return;
346
369
    }
347
370
}
348
371
 
349
 
 
350
 
 
351
372
BYTE REGPARM1 vic_read(WORD addr)
352
373
{
353
374
    addr &= 0xf;
367
388
    }
368
389
}
369
390
 
 
391
/* This function is only used by mem_get_screen_parameter(),
 
392
   so all we return is the regs. Change this if it ever gets
 
393
   used for other things. */
 
394
BYTE REGPARM1 vic_peek(WORD addr)
 
395
{
 
396
    addr &= 0xf;
 
397
 
 
398
    return vic.regs[addr];
 
399
}