~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/vicii/vicii-mem.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090331003715-mzclchtl0dp7fcl0
Tags: upstream-2.1.dfsg
ImportĀ upstreamĀ versionĀ 2.1.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *  Ettore Perazzoli <ettore@comm2000.it>
6
6
 *  Andreas Boose <viceteam@t-online.de>
7
7
 *
 
8
 * DTV sections written by
 
9
 *  Hannu Nuotio <hannu.nuotio@tut.fi>
 
10
 *  Daniel Kahlin <daniel@kahlin.net>
 
11
 *
8
12
 * This file is part of VICE, the Versatile Commodore Emulator.
9
13
 * See README for copyright notice.
10
14
 *
49
53
 
50
54
 
51
55
/* Unused bits in VIC-II registers: these are always 1 when read.  */
52
 
static int unused_bits_in_registers[64] =
 
56
static int unused_bits_in_registers[0x50] =
53
57
{
54
58
    0x00 /* $D000 */ , 0x00 /* $D001 */ , 0x00 /* $D002 */ , 0x00 /* $D003 */ ,
55
59
    0x00 /* $D004 */ , 0x00 /* $D005 */ , 0x00 /* $D006 */ , 0x00 /* $D007 */ ,
59
63
    0x00 /* $D014 */ , 0x00 /* $D015 */ , 0x00 /* $D016 */ , 0xc0 /* $D017 */ ,
60
64
    0x01 /* $D018 */ , 0x70 /* $D019 */ , 0xf0 /* $D01A */ , 0x00 /* $D01B */ ,
61
65
    0x00 /* $D01C */ , 0x00 /* $D01D */ , 0x00 /* $D01E */ , 0x00 /* $D01F */ ,
62
 
    0xf0 /* $D020 */ , 0xf0 /* $D021 */ , 0xf0 /* $D022 */ , 0xf0 /* $D023 */ ,
63
 
    0xf0 /* $D024 */ , 0xf0 /* $D025 */ , 0xf0 /* $D026 */ , 0xf0 /* $D027 */ ,
 
66
    0x00 /* $D020 */ , 0x00 /* $D021 */ , 0x00 /* $D022 */ , 0x00 /* $D023 */ ,
 
67
    0x00 /* $D024 */ , 0xf0 /* $D025 */ , 0xf0 /* $D026 */ , 0xf0 /* $D027 */ ,
64
68
    0xf0 /* $D028 */ , 0xf0 /* $D029 */ , 0xf0 /* $D02A */ , 0xf0 /* $D02B */ ,
65
69
    0xf0 /* $D02C */ , 0xf0 /* $D02D */ , 0xf0 /* $D02E */ , 0xff /* $D02F */ ,
66
70
    0xff /* $D030 */ , 0xff /* $D031 */ , 0xff /* $D032 */ , 0xff /* $D033 */ ,
67
 
    0xff /* $D034 */ , 0xff /* $D035 */ , 0xff /* $D036 */ , 0xff /* $D037 */ ,
68
 
    0xff /* $D038 */ , 0xff /* $D039 */ , 0xff /* $D03A */ , 0xff /* $D03B */ ,
69
 
    0xff /* $D03C */ , 0xff /* $D03D */ , 0xff /* $D03E */ , 0xff /* $D03F */
 
71
    0xff /* $D034 */ , 0xff /* $D035 */ , 0x00 /* $D036 */ , 0x00 /* $D037 */ ,
 
72
    0x00 /* $D038 */ , 0xf0 /* $D039 */ , 0x00 /* $D03A */ , 0x00 /* $D03B */ ,
 
73
    0x80 /* $D03C */ , 0x00 /* $D03D */ , 0xff /* $D03E */ , 0xfc /* $D03F */ ,
 
74
    0xf8 /* $D040 */ , 0x00 /* $D041 */ , 0x00 /* $D042 */ , 0x00 /* $D043 */ ,
 
75
    0x80 /* $D044 */ , 0xc0 /* $D045 */ , 0x00 /* $D046 */ , 0x00 /* $D047 */ ,
 
76
    0xf0 /* $D048 */ , 0x00 /* $D049 */ , 0x00 /* $D04A */ , 0xc0 /* $D04B */ ,
 
77
    0x00 /* $D04C */ , 0xc0 /* $D04D */ , 0x00 /* $D04E */ , 0xf0 /* $D04F */
70
78
};
71
79
 
72
80
 
249
257
                       blanking.  */
250
258
                    vicii.raster.blank_enabled = 0;
251
259
                }
 
260
 
 
261
                if (line == vicii.raster.display_ystart && cycle > 0
 
262
                    && vicii.raster.blank == 0) {
 
263
                    /* A 24 -> 25 switch somewhere on the first line of
 
264
                       the 25-row mode is enough to disable screen
 
265
                       blanking even if blank bit is switched on in the
 
266
                       same cycle (and set later in d011_store) */
 
267
                    vicii.raster.blank_enabled = 0;
 
268
                }
252
269
            }
253
270
            VICII_DEBUG_REGISTER(("25 line mode enabled"));
254
271
        } else {
271
288
            VICII_DEBUG_REGISTER(("24 line mode enabled"));
272
289
        }
273
290
    }
 
291
 
 
292
    /* Check if border is already disabled even if DEN will be cleared */
 
293
    if (line == vicii.raster.display_ystart && cycle > 0 && !vicii.raster.blank)
 
294
    {
 
295
        vicii.raster.blank_off = 1;
 
296
    }
274
297
}
275
298
 
276
299
inline static void d011_store(BYTE value)
290
313
    /* This is the funniest part... handle bad line tricks.  */
291
314
    old_allow_bad_lines = vicii.allow_bad_lines;
292
315
 
 
316
    if (line == vicii.first_dma_line && cycle == 0)
 
317
        vicii.allow_bad_lines = (value & 0x10) ? 1 : 0;
 
318
 
293
319
    if (VICII_RASTER_Y(maincpu_clk - 1) == vicii.first_dma_line
294
320
        && (value & 0x10) != 0)
295
321
        vicii.allow_bad_lines = 1;
358
384
             && cycle > VICII_FETCH_CYCLE
359
385
             && cycle <= vicii.sprite_fetch_cycle)
360
386
            || vicii.raster.current_line < vicii.first_dma_line
361
 
            || vicii.raster.current_line > vicii.last_dma_line) {
 
387
            || vicii.raster.current_line >= vicii.last_dma_line) {
362
388
            CLOCK new_fetch_clk;
363
389
 
364
390
            new_fetch_clk = (VICII_LINE_START_CLK(maincpu_clk)
468
494
                                              VICII_RASTER_X(cycle),
469
495
                                              &raster->xsmooth_shift_right,
470
496
                                              xsmooth - (vicii.regs[0x16] & 7));
 
497
            raster_changes_sprites_add_int(raster,
 
498
                                           VICII_RASTER_X(cycle) + 8 
 
499
                                                + (vicii.regs[0x16] & 7),
 
500
                                           &raster->sprite_xsmooth_shift_right,
 
501
                                           1);
471
502
        }
472
503
        raster_changes_foreground_add_int(raster,
473
504
                                          VICII_RASTER_CHAR(cycle) - 1,
474
505
                                          &raster->xsmooth,
475
506
                                          xsmooth);
 
507
        raster_changes_sprites_add_int(raster,
 
508
                                        VICII_RASTER_X(cycle) + 8 + xsmooth,
 
509
                                        &raster->sprite_xsmooth,
 
510
                                        xsmooth);
476
511
    }
477
512
 
478
513
    /* Bit 4 (CSEL) selects 38/40 column mode.  */
510
545
            if (cycle == 15)
511
546
                sprite->memptr_inc
512
547
                    = vicii_sprites_crunch_table[sprite->memptr];
513
 
            else if (cycle < 15)
 
548
            else if (cycle < 15 || cycle >= vicii.sprite_fetch_cycle)
514
549
                sprite->memptr_inc = 3;
515
550
            sprite->exp_flag = 1;
516
551
        }
539
574
        vicii.irq_status &= ~((vicii.last_read & 0xf) | 0x80);
540
575
        if (maincpu_clk - 1 > vicii.raster_irq_clk
541
576
            && vicii.raster_irq_line < (unsigned int)vicii.screen_height) {
542
 
            vicii_irq_next_frame();
 
577
                if (maincpu_clk - 2 == vicii.raster_irq_clk)
 
578
                    vicii_irq_next_frame();
 
579
                else
 
580
                    vicii_irq_alarm_handler(0, NULL);
543
581
        }
544
582
    }
545
583
 
546
584
    if ((value & 1) && maincpu_clk > vicii.raster_irq_clk
547
585
        && vicii.raster_irq_line < (unsigned int)vicii.screen_height) {
548
 
        vicii_irq_next_frame();
 
586
            if (maincpu_clk - 1 == vicii.raster_irq_clk)
 
587
                vicii_irq_next_frame();
 
588
            else
 
589
                vicii_irq_alarm_handler(0, NULL);
549
590
    }
550
591
 
551
592
    vicii.irq_status &= ~((value & 0xf) | 0x80);
560
601
 
561
602
    vicii_irq_set_line();
562
603
 
563
 
    VICII_DEBUG_REGISTER(("IRQ mask register: $%02X", vicii.regs[addr]));
 
604
/*    VICII_DEBUG_REGISTER(("IRQ mask register: $%02X", vicii.regs[addr])); */
564
605
}
565
606
 
566
607
inline static void d01b_store(const BYTE value)
615
656
 
616
657
        if ((vicii.regs[0x1c] & b) != (value & b)) {
617
658
            /* Test for MC bug condition */
618
 
            sprite_x = (vicii.regs[2 * i] | (vicii.regs[0x10] & b ? 0x100 : 0));
 
659
            sprite_x = (vicii.regs[2 * i] | (vicii.regs[0x10] & b ? 0x100 : 0))
 
660
                    + vicii.screen_leftborderwidth - 0x20;
619
661
            x_exp = vicii.regs[0x1d] & b;
620
662
            delayed_pixel = 6;
621
663
 
710
752
{
711
753
    VICII_DEBUG_REGISTER(("Border color register: $%02X", value));
712
754
 
713
 
    value &= 0xf;
 
755
    if (!vicii.extended_enable)
 
756
        value = (vicii.regs[0x20] & 0xf0) | (value & 0x0f);
714
757
 
715
 
    if (vicii.regs[0x20] == value)
 
758
    if (!vicii.viciidtv && (vicii.regs[0x20] == value))
716
759
        return;
717
760
 
718
761
    vicii.regs[0x20] = value;
719
762
 
720
763
    raster_changes_border_add_int(&vicii.raster,
721
 
        VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk)),
 
764
        vicii.viciidtv?VICIIDTV_RASTER_X_ADJ(VICII_RASTER_CYCLE(maincpu_clk)):VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk)),
722
765
        (int *)&vicii.raster.border_color,
723
 
        value);
 
766
        vicii.viciidtv?vicii.dtvpalette[value]:value);
724
767
}
725
768
 
726
769
inline static void d021_store(BYTE value)
727
770
{
728
771
    int x_pos;
 
772
    BYTE cmask;
 
773
    cmask = (vicii.high_color) ? 0xff : 0x0f;
729
774
 
730
 
    value &= 0xf;
 
775
    if (!vicii.extended_enable)
 
776
        value = (vicii.regs[0x21] & 0xf0) | (value & 0x0f);
731
777
 
732
778
    VICII_DEBUG_REGISTER(("Background #0 color register: $%02X", value));
733
779
 
734
 
    if (vicii.regs[0x21] == value)
 
780
    if (!vicii.viciidtv && (vicii.regs[0x21] == value))
735
781
        return;
736
782
 
737
 
    x_pos = VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk));
 
783
    x_pos = vicii.viciidtv?VICIIDTV_RASTER_X_ADJ(VICII_RASTER_CYCLE(maincpu_clk)):VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk));
738
784
 
739
785
    if (!vicii.force_black_overscan_background_color) {
740
786
        raster_changes_background_add_int(&vicii.raster, x_pos,
741
787
                                          &vicii.raster.idle_background_color,
742
 
                                          value);
 
788
                                          vicii.viciidtv?vicii.dtvpalette[value & cmask]:value);
743
789
        raster_changes_background_add_int(&vicii.raster, x_pos,
744
 
                                          &vicii.raster.xsmooth_color, value);
 
790
                                          &vicii.raster.xsmooth_color, 
 
791
                                          vicii.viciidtv?vicii.dtvpalette[value & cmask]:value);
745
792
    }
746
793
 
747
794
    raster_changes_background_add_int(&vicii.raster, x_pos,
748
795
                                      (int *)&vicii.raster.background_color,
749
 
                                      value);
 
796
                                      vicii.viciidtv?vicii.dtvpalette[value & cmask]:value);
750
797
    vicii.regs[0x21] = value;
751
798
}
752
799
 
754
801
{
755
802
    int char_num;
756
803
 
757
 
    value &= 0xf;
 
804
    BYTE cmask;
 
805
    cmask = (vicii.high_color) ? 0xff : 0x0f;
 
806
 
 
807
    if (!vicii.extended_enable)
 
808
        value = (vicii.regs[addr] & 0xf0) | (value & 0x0f);
758
809
 
759
810
    VICII_DEBUG_REGISTER(("Background color #%d register: $%02X",
760
811
                          addr - 0x21, value));
761
812
 
762
 
    if (vicii.regs[addr] == value)
 
813
    if (!vicii.viciidtv && (vicii.regs[addr] == value))
763
814
        return;
764
815
 
765
816
    vicii.regs[addr] = value;
776
827
    raster_changes_foreground_add_int(&vicii.raster,
777
828
                                      char_num - 1,
778
829
                                      &vicii.ext_background_color[addr - 0x22],
779
 
                                      value);
 
830
                                      vicii.viciidtv?vicii.dtvpalette[value & cmask]:value);
780
831
}
781
832
 
782
833
inline static void d025_store(BYTE value)
787
838
 
788
839
    VICII_DEBUG_REGISTER(("Sprite multicolor register #0: $%02X", value));
789
840
 
790
 
    if (vicii.regs[0x25] == value)
 
841
    if (!vicii.viciidtv && (vicii.regs[0x25] == value))
791
842
        return;
792
843
 
793
844
    sprite_status = vicii.raster.sprite_status;
794
845
 
795
846
    raster_changes_sprites_add_int(&vicii.raster,
796
847
        VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk)) + 1,
797
 
        (int *)&sprite_status->mc_sprite_color_1, (int)value);
 
848
        (int *)&sprite_status->mc_sprite_color_1, 
 
849
        vicii.viciidtv?(int)vicii.dtvpalette[value]:(int)value);
798
850
 
799
851
    vicii.regs[0x25] = value;
800
852
}
807
859
 
808
860
    VICII_DEBUG_REGISTER(("Sprite multicolor register #1: $%02X", value));
809
861
 
810
 
    if (vicii.regs[0x26] == value)
 
862
    if (!vicii.viciidtv && (vicii.regs[0x26] == value))
811
863
        return;
812
864
 
813
865
    sprite_status = vicii.raster.sprite_status;
814
866
 
815
867
    raster_changes_sprites_add_int(&vicii.raster,
816
868
        VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk)) + 1,
817
 
        (int*)&sprite_status->mc_sprite_color_2, (int)value);
 
869
        (int*)&sprite_status->mc_sprite_color_2, 
 
870
        vicii.viciidtv?(int)vicii.dtvpalette[value]:(int)value);
818
871
 
819
872
    vicii.regs[0x26] = value;
820
873
}
829
882
    VICII_DEBUG_REGISTER(("Sprite #%d color register: $%02X",
830
883
                         addr - 0x27, value));
831
884
 
832
 
    if (vicii.regs[addr] == value)
 
885
    if (!vicii.viciidtv && (vicii.regs[addr] == value))
833
886
        return;
834
887
 
835
888
    n = addr - 0x27;
838
891
 
839
892
        raster_changes_sprites_add_int(&vicii.raster,
840
893
            VICII_RASTER_X(VICII_RASTER_CYCLE(maincpu_clk)) + 1,
841
 
            (int *)&sprite->color, value);
 
894
            (int *)&sprite->color, 
 
895
            vicii.viciidtv?vicii.dtvpalette[value]:value);
842
896
 
843
897
    vicii.regs[addr] = value;
844
898
}
867
921
    }
868
922
}
869
923
 
 
924
extern BYTE mem_ram[];
 
925
 
 
926
void viciidtv_update_colorram()
 
927
{
 
928
    vicii.color_ram_ptr = mem_ram
 
929
        + (vicii.regs[0x36] << 10)
 
930
        + ((vicii.regs[0x37] & 0x07) << 18); /* TODO test */
 
931
}
 
932
 
 
933
inline static void d036_store(const BYTE value)
 
934
{
 
935
    if (vicii.extended_enable) {
 
936
        vicii.regs[0x36] = value;
 
937
        viciidtv_update_colorram();
 
938
    }
 
939
    
 
940
    VICII_DEBUG_REGISTER(("Color bank low: $%02x",value));
 
941
}
 
942
 
 
943
inline static void d037_store(const BYTE value)
 
944
{
 
945
    if (vicii.extended_enable) {
 
946
        vicii.regs[0x37] = value;
 
947
        viciidtv_update_colorram();
 
948
    }
 
949
    VICII_DEBUG_REGISTER(("Color bank high: $%02x",value));
 
950
}
 
951
 
 
952
inline static void d038_store(const BYTE value)
 
953
{
 
954
    if (vicii.extended_enable) {
 
955
        vicii.regs[0x38] = value;
 
956
        vicii.counta_mod &= 0xff00;
 
957
        vicii.counta_mod |= value;
 
958
    }
 
959
 
 
960
    VICII_DEBUG_REGISTER(("Linear Count A modulo low: $%02x",value));
 
961
}
 
962
 
 
963
inline static void d039_store(const BYTE value)
 
964
{
 
965
    if (vicii.extended_enable) {
 
966
        vicii.regs[0x39] = value & 0xf;
 
967
        vicii.counta_mod &= 0x00ff;
 
968
        vicii.counta_mod |= ((value&0xf)<<8);
 
969
    }
 
970
 
 
971
    VICII_DEBUG_REGISTER(("Linear Count A modulo high: $%02x",value));
 
972
}
 
973
 
 
974
inline static void d03a_store(const BYTE value)
 
975
{
 
976
    if (vicii.extended_enable) {
 
977
        vicii.regs[0x3a] = value;
 
978
        vicii_update_memory_ptrs(VICII_RASTER_CYCLE(maincpu_clk));
 
979
    }
 
980
 
 
981
    VICII_DEBUG_REGISTER(("Linear Count A Start low: $%02x",value));
 
982
}
 
983
 
 
984
inline static void d03b_store(const BYTE value)
 
985
{
 
986
    if (vicii.extended_enable) {
 
987
        vicii.regs[0x3b] = value;
 
988
        vicii_update_memory_ptrs(VICII_RASTER_CYCLE(maincpu_clk));
 
989
    }
 
990
 
 
991
    VICII_DEBUG_REGISTER(("Linear Count A Start middle: $%02x",value));
 
992
}
 
993
 
 
994
static void d03c_store(const BYTE value)
 
995
{
 
996
    int cycle, old_overscan;
 
997
  
 
998
    if (!vicii.extended_enable) {
 
999
        return;
 
1000
    }
 
1001
 
 
1002
    cycle = VICII_RASTER_CYCLE(maincpu_clk);
 
1003
    old_overscan = vicii.overscan;
 
1004
    vicii.regs[0x3c] = value;
 
1005
    vicii.badline_disable = value & 0x20 ? 1 : 0;
 
1006
    vicii.colorfetch_disable = value & 0x10 ? 1: 0;
 
1007
    vicii.overscan = value & 0x08 ? 1 : 0;
 
1008
    vicii.high_color = value & 0x04 ? 1 : 0;
 
1009
    vicii.border_off = value & 0x02 ? 1 : 0;
 
1010
 
 
1011
    /* make some of those constants below into defines */
 
1012
    raster_changes_border_add_int(&vicii.raster,
 
1013
        VICIIDTV_RASTER_X_ADJ(cycle),
 
1014
        (int *)&vicii.raster.border_disable,
 
1015
        vicii.border_off);
 
1016
 
 
1017
    if (vicii.overscan) {
 
1018
        vicii.raster.geometry->gfx_size.width = VICII_SCREEN_XPIX+64;
 
1019
        vicii.raster.geometry->text_size.width = VICII_SCREEN_TEXTCOLS + 8;
 
1020
        vicii.raster.geometry->gfx_position.x = vicii.screen_leftborderwidth - 32;
 
1021
        if (!old_overscan) { /* TODO should happen max. once per line */
 
1022
            /* remove the 8 extra counter increments for the current line */
 
1023
            vicii.counta -= vicii.counta_step * 8;
 
1024
            vicii.countb -= vicii.countb_step * 8;
 
1025
        }
 
1026
    } else {
 
1027
        vicii.raster.geometry->gfx_size.width = VICII_SCREEN_XPIX;
 
1028
        vicii.raster.geometry->text_size.width = VICII_SCREEN_TEXTCOLS;
 
1029
        vicii.raster.geometry->gfx_position.x = vicii.screen_leftborderwidth;
 
1030
    }
 
1031
 
 
1032
    d020_store((BYTE)vicii.regs[0x20]);
 
1033
    d021_store((BYTE)vicii.regs[0x21]);
 
1034
    ext_background_store(0x22,(BYTE)vicii.regs[0x22]);
 
1035
    ext_background_store(0x23,(BYTE)vicii.regs[0x23]);
 
1036
    ext_background_store(0x24,(BYTE)vicii.regs[0x24]);
 
1037
 
 
1038
    vicii_update_video_mode(cycle);
 
1039
    vicii_update_memory_ptrs(cycle);
 
1040
 
 
1041
    VICII_DEBUG_REGISTER(("VICIIDTV register 1: $%02x",value));
 
1042
}
 
1043
 
 
1044
inline static void d03d_store(const BYTE value)
 
1045
{
 
1046
    if (vicii.extended_enable) {
 
1047
        vicii.regs[0x3d] = value & 0x1f;
 
1048
        vicii_update_memory_ptrs(VICII_RASTER_CYCLE(maincpu_clk));
 
1049
    }
 
1050
    
 
1051
    VICII_DEBUG_REGISTER(("Graphics fetch bank: $%02x",value));
 
1052
}
 
1053
 
 
1054
inline static void d03f_store(const BYTE value)
 
1055
{
 
1056
    if (vicii.extended_lockout) {
 
1057
        return;
 
1058
    }
 
1059
 
 
1060
    vicii.extended_enable = value & 0x01 ? 1 : 0;
 
1061
    vicii.extended_lockout = value & 0x02 ? 1 : 0;
 
1062
 
 
1063
    vicii.regs[0x3f] = value;
 
1064
 
 
1065
    VICII_DEBUG_REGISTER(("Enable extended features: $%02x",value));
 
1066
}
 
1067
 
 
1068
int vicii_extended_regs(void)
 
1069
{
 
1070
    return vicii.extended_enable;
 
1071
}
 
1072
 
 
1073
 
 
1074
inline static void d040_store(const BYTE value)
 
1075
{
 
1076
    if (vicii.extended_enable) {
 
1077
        vicii.regs[0x40] = value;
 
1078
    }
 
1079
 
 
1080
    VICII_DEBUG_REGISTER(("VICIIDTV register 2: $%02x",value));
 
1081
}
 
1082
 
 
1083
inline static void d044_store(const BYTE value)
 
1084
{
 
1085
    int offs;
 
1086
 
 
1087
    if (vicii.extended_enable) {
 
1088
        vicii.regs[0x44] = value;
 
1089
 
 
1090
        offs = value & 0x7f;
 
1091
        vicii.raster_irq_prevent = 0;
 
1092
        if (offs <= 64) {
 
1093
            if (vicii.cycles_per_line == 63 && offs > 53) {
 
1094
                if (offs == 54 || offs == 55) {
 
1095
                    vicii.raster_irq_prevent = 1;
 
1096
                }
 
1097
                offs -= 2;
 
1098
            }
 
1099
            vicii.raster_irq_offset = (offs+1) % vicii.cycles_per_line;
 
1100
        } else {
 
1101
            vicii.raster_irq_prevent = 1;
 
1102
        }
 
1103
        vicii_irq_set_raster_line(vicii.raster_irq_line);
 
1104
    }
 
1105
    VICII_DEBUG_REGISTER(("CPU cycle/IRQ trigger cycle: $%02x",value));
 
1106
}
 
1107
 
 
1108
inline static void d045_store(const BYTE value)
 
1109
{
 
1110
    if (vicii.extended_enable) {
 
1111
        vicii.regs[0x45] = value&0x1f;
 
1112
        viciidtv_update_colorram();
 
1113
        vicii_update_memory_ptrs(VICII_RASTER_CYCLE(maincpu_clk));
 
1114
    }
 
1115
 
 
1116
    VICII_DEBUG_REGISTER(("Linear Count A Start high: $%02x",value));
 
1117
}
 
1118
 
 
1119
inline static void d046_store(const BYTE value)
 
1120
{
 
1121
    if (vicii.extended_enable) {
 
1122
        vicii.regs[0x46] = value;
 
1123
        vicii.counta_step = value;
 
1124
    }
 
1125
 
 
1126
    VICII_DEBUG_REGISTER(("Linear Count A Step: $%02x",value));
 
1127
}
 
1128
 
 
1129
inline static void d047_store(const BYTE value)
 
1130
{
 
1131
    if (vicii.extended_enable) {
 
1132
        vicii.regs[0x47] = value;
 
1133
        vicii.countb_mod &= 0xff00;
 
1134
        vicii.countb_mod |= value;
 
1135
    }
 
1136
 
 
1137
    VICII_DEBUG_REGISTER(("Linear Count B modulo low: $%02x",value));
 
1138
}
 
1139
 
 
1140
inline static void d048_store(const BYTE value)
 
1141
{
 
1142
    if (vicii.extended_enable) {
 
1143
        vicii.regs[0x48] = value & 0xf;
 
1144
        vicii.countb_mod &= 0x00ff;
 
1145
        vicii.countb_mod |= ((value&0xf)<<8);
 
1146
    }
 
1147
 
 
1148
    VICII_DEBUG_REGISTER(("Linear Count B modulo high: $%02x",value));
 
1149
}
 
1150
 
 
1151
inline static void d049_store(const BYTE value)
 
1152
{
 
1153
    if (vicii.extended_enable) {
 
1154
        vicii.regs[0x49] = value;
 
1155
    }
 
1156
 
 
1157
    VICII_DEBUG_REGISTER(("Linear Count B Start low: $%02x",value));
 
1158
}
 
1159
 
 
1160
inline static void d04a_store(const BYTE value)
 
1161
{
 
1162
    if (vicii.extended_enable) {
 
1163
        vicii.regs[0x4a] = value;
 
1164
    }
 
1165
 
 
1166
    VICII_DEBUG_REGISTER(("Linear Count B Start middle: $%02x",value));
 
1167
}
 
1168
 
 
1169
inline static void d04b_store(const BYTE value)
 
1170
{
 
1171
    if (vicii.extended_enable) {
 
1172
        vicii.regs[0x4b] = value&0x1f;
 
1173
    }
 
1174
 
 
1175
    VICII_DEBUG_REGISTER(("Linear Count B Start high: $%02x",value));
 
1176
}
 
1177
 
 
1178
inline static void d04c_store(const BYTE value)
 
1179
{
 
1180
    if (vicii.extended_enable) {
 
1181
        vicii.regs[0x4c] = value;
 
1182
        vicii.countb_step = value;
 
1183
    }
 
1184
 
 
1185
    VICII_DEBUG_REGISTER(("Linear Count B Step: $%02x",value));
 
1186
}
 
1187
 
 
1188
inline static void d04d_store(const BYTE value)
 
1189
{
 
1190
    if (vicii.extended_enable) {
 
1191
        vicii.regs[0x4d] = value & 0x1f;
 
1192
    }
 
1193
 
 
1194
    VICII_DEBUG_REGISTER(("Sprite bank: $%02x",value));
 
1195
}
 
1196
 
 
1197
/* DTV Palette registers at $d2xx */
 
1198
void REGPARM2 vicii_palette_store(WORD addr, BYTE value)
 
1199
{
 
1200
    if (!vicii.extended_enable) {
 
1201
        return;
 
1202
    }
 
1203
 
 
1204
    if (vicii.dtvpalette[addr&0xf]==value) {
 
1205
        return;
 
1206
    }
 
1207
 
 
1208
    vicii.dtvpalette[addr&0xf]=value;
 
1209
    d020_store((BYTE)vicii.regs[0x20]);
 
1210
    d021_store((BYTE)vicii.regs[0x21]);
 
1211
    ext_background_store(0x22,(BYTE)vicii.regs[0x22]);
 
1212
    ext_background_store(0x23,(BYTE)vicii.regs[0x23]);
 
1213
    ext_background_store(0x24,(BYTE)vicii.regs[0x24]);
 
1214
    d025_store((BYTE)vicii.regs[0x25]);
 
1215
    d026_store((BYTE)vicii.regs[0x26]);
 
1216
    sprite_color_store(0x27,(BYTE)vicii.regs[0x27]);
 
1217
    sprite_color_store(0x28,(BYTE)vicii.regs[0x28]);
 
1218
    sprite_color_store(0x29,(BYTE)vicii.regs[0x29]);
 
1219
    sprite_color_store(0x2a,(BYTE)vicii.regs[0x2a]);
 
1220
    sprite_color_store(0x2b,(BYTE)vicii.regs[0x2b]);
 
1221
    sprite_color_store(0x2c,(BYTE)vicii.regs[0x2c]);
 
1222
    sprite_color_store(0x2d,(BYTE)vicii.regs[0x2d]);
 
1223
    sprite_color_store(0x2e,(BYTE)vicii.regs[0x2e]);
 
1224
    vicii.raster.dont_cache = 1;
 
1225
}
 
1226
 
 
1227
BYTE REGPARM1 vicii_palette_read(WORD addr)
 
1228
{
 
1229
    return 0;
 
1230
}
 
1231
 
870
1232
/* Store a value in a VIC-II register.  */
871
1233
void REGPARM2 vicii_store(WORD addr, BYTE value)
872
1234
{
873
 
    addr &= 0x3f;
 
1235
    if (vicii.extended_enable) addr &= 0x7f;
 
1236
    else addr &= 0x3f;
874
1237
 
875
1238
    vicii_handle_pending_alarms_external_write();
876
1239
 
1014
1377
      case 0x33:                  /* $D033: Unused */
1015
1378
      case 0x34:                  /* $D034: Unused */
1016
1379
      case 0x35:                  /* $D035: Unused */
1017
 
      case 0x36:                  /* $D036: Unused */
1018
 
      case 0x37:                  /* $D037: Unused */
1019
 
      case 0x38:                  /* $D038: Unused */
1020
 
      case 0x39:                  /* $D039: Unused */
1021
 
      case 0x3a:                  /* $D03A: Unused */
1022
 
      case 0x3b:                  /* $D03B: Unused */
1023
 
      case 0x3c:                  /* $D03C: Unused */
1024
 
      case 0x3d:                  /* $D03D: Unused */
1025
1380
      case 0x3e:                  /* $D03E: Unused */
1026
 
      case 0x3f:                  /* $D03F: Unused */
 
1381
      case 0x50:
 
1382
      case 0x51:
 
1383
      case 0x52:
 
1384
      case 0x53:
 
1385
      case 0x54:
 
1386
      case 0x55:
 
1387
      case 0x56:
 
1388
      case 0x57:
 
1389
      case 0x58:
 
1390
      case 0x59:
 
1391
      case 0x5a:
 
1392
      case 0x5b:
 
1393
      case 0x5c:
 
1394
      case 0x5d:
 
1395
      case 0x5e:
 
1396
      case 0x5f:
 
1397
      case 0x60:
 
1398
      case 0x61:
 
1399
      case 0x62:
 
1400
      case 0x63:
 
1401
      case 0x64:
 
1402
      case 0x65:
 
1403
      case 0x66:
 
1404
      case 0x67:
 
1405
      case 0x68:
 
1406
      case 0x69:
 
1407
      case 0x6a:
 
1408
      case 0x6b:
 
1409
      case 0x6c:
 
1410
      case 0x6d:
 
1411
      case 0x6e:
 
1412
      case 0x6f:
 
1413
      case 0x70:
 
1414
      case 0x71:
 
1415
      case 0x72:
 
1416
      case 0x73:
 
1417
      case 0x74:
 
1418
      case 0x75:
 
1419
      case 0x76:
 
1420
      case 0x77:
 
1421
      case 0x78:
 
1422
      case 0x79:
 
1423
      case 0x7a:
 
1424
      case 0x7b:
 
1425
      case 0x7c:
 
1426
      case 0x7d:
 
1427
      case 0x7e:
 
1428
      case 0x7f:
1027
1429
        VICII_DEBUG_REGISTER(("(unused)"));
1028
1430
        break;
 
1431
 
 
1432
      case 0x36:                  /* $D036: Color Bank Low */
 
1433
        d036_store(value);
 
1434
        break;
 
1435
      case 0x37:                  /* $D037: Color Bank High */
 
1436
        d037_store(value);
 
1437
        break;
 
1438
      case 0x38:                  /* $D038: Linear Count A Modulo Low */
 
1439
        d038_store(value);
 
1440
        break;
 
1441
      case 0x39:                  /* $D039: Linear Count A Modulo High */
 
1442
        d039_store(value);
 
1443
        break;
 
1444
      case 0x3a:                  /* $D03a: Linear Count A Start Low */
 
1445
        d03a_store(value);
 
1446
        break;
 
1447
      case 0x3b:                  /* $D03B: Linear Count A Start Middle */
 
1448
        d03b_store(value);
 
1449
        break;
 
1450
      case 0x3c:                  /* $D03C: VICIIDTV register 1 */
 
1451
        d03c_store(value);
 
1452
        break;
 
1453
      case 0x3d:                  /* $D03D: Graphics fetch bank */
 
1454
        d03d_store(value);
 
1455
        break;
 
1456
      case 0x3f:                  /* $D03F: Enable extended features register */
 
1457
        d03f_store(value);
 
1458
        break;
 
1459
      case 0x40:                  /* $D040: VICIIDTV register 2 */
 
1460
        d040_store(value);
 
1461
        break;
 
1462
      case 0x41:                  /* $D041: Burst rate modulus high */
 
1463
      case 0x42:                  /* $D042: Burst rate modulus middle */
 
1464
      case 0x43:                  /* $D043: Burst rate modulus low */
 
1465
        VICII_DEBUG_REGISTER(("Burst rate modulus (ignored)"));
 
1466
        break;
 
1467
      case 0x44:                  /* $D044: CPU cycle/IRQ trigger cycle */
 
1468
        d044_store(value);
 
1469
        break;
 
1470
      case 0x45:                  /* $D045: Linear Count A Start High */
 
1471
        d045_store(value);
 
1472
        break;
 
1473
      case 0x46:                  /* $D046: Linear Count A Step */
 
1474
        d046_store(value);
 
1475
        break;
 
1476
      case 0x47:                  /* $D047: Linear Count B Modulo Low */
 
1477
        d047_store(value);
 
1478
        break;
 
1479
      case 0x48:                  /* $D048: Linear Count B Modulo High */
 
1480
        d048_store(value);
 
1481
        break;
 
1482
      case 0x49:                  /* $D049: Linear Count B Start Low */
 
1483
        d049_store(value);
 
1484
        break;
 
1485
      case 0x4a:                  /* $D04A: Linear Count B Start Middle */
 
1486
        d04a_store(value);
 
1487
        break;
 
1488
      case 0x4b:                  /* $D04B: Linear Count B Start High */
 
1489
        d04b_store(value);
 
1490
        break;
 
1491
      case 0x4c:                  /* $D04C: Linear Count B Step */
 
1492
        d04c_store(value);
 
1493
        break;
 
1494
      case 0x4d:                  /* $D04D: Sprite bank */
 
1495
        d04d_store(value);
 
1496
        break;
 
1497
      case 0x4e:                  /* $D04E: Scan line timing adjust */
 
1498
      case 0x4f:                  /* $D04F: VICIIDTV register 3 */
 
1499
        VICII_DEBUG_REGISTER(("Scan line/Saturation/Burst lock (ignored)"));
 
1500
        break;
1029
1501
    }
1030
1502
}
1031
1503
 
1076
1548
        vicii.last_read = vicii.irq_status | 0x70;
1077
1549
    }
1078
1550
 
1079
 
    return vicii.last_read;
 
1551
    return vicii.viciidtv?vicii.last_read | ((vicii.last_read&0xf) ? 0x80 : 0x00):vicii.last_read;
1080
1552
}
1081
1553
 
1082
1554
inline static BYTE d01e_read(void)
1083
1555
{
1084
1556
    /* Remove the pending sprite-sprite interrupt, as the collision
1085
1557
       register is reset upon read accesses.  */
1086
 
    vicii_irq_sscoll_clear();
 
1558
    if (!vicii.viciidtv)
 
1559
        vicii_irq_sscoll_clear();
1087
1560
 
1088
1561
    if (!vicii_resources.sprite_sprite_collisions_enabled) {
1089
1562
        VICII_DEBUG_REGISTER(("Sprite-sprite collision mask: $00 "
1104
1577
{
1105
1578
    /* Remove the pending sprite-background interrupt, as the collision
1106
1579
       register is reset upon read accesses.  */
1107
 
    vicii_irq_sbcoll_clear();
 
1580
    if (!vicii.viciidtv)
 
1581
        vicii_irq_sbcoll_clear();
1108
1582
 
1109
1583
    if (!vicii_resources.sprite_background_collisions_enabled) {
1110
1584
        VICII_DEBUG_REGISTER(("Sprite-background collision mask: $00 "
1128
1602
    return vicii.regs[0x1f];
1129
1603
}
1130
1604
 
 
1605
inline static BYTE d044_read(void)
 
1606
{
 
1607
    return VICIIDTV_RASTER_CYCLE(maincpu_clk) | 0x80;
 
1608
}
 
1609
 
1131
1610
/* Read a value from a VIC-II register.  */
1132
1611
BYTE REGPARM1 vicii_read(WORD addr)
1133
1612
{
1134
 
    addr &= 0x3f;
 
1613
    if (vicii.extended_enable) addr &= 0x7f;
 
1614
    else addr &= 0x3f;
1135
1615
 
1136
1616
    /* Serve all pending events.  */
1137
1617
    vicii_handle_pending_alarms(0);
1244
1724
      case 0x20:                  /* $D020: Border color */
1245
1725
        VICII_DEBUG_REGISTER(("Border Color register: $%02X",
1246
1726
                             vicii.regs[addr]));
1247
 
        return vicii.regs[addr] | 0xf0;
 
1727
        return vicii.viciidtv?vicii.regs[addr]:(vicii.regs[addr] | 0xf0);
1248
1728
 
1249
1729
      case 0x21:                  /* $D021: Background #0 color */
1250
1730
      case 0x22:                  /* $D022: Background #1 color */
1252
1732
      case 0x24:                  /* $D024: Background #3 color */
1253
1733
        VICII_DEBUG_REGISTER(("Background Color #%d register: $%02X",
1254
1734
                             addr - 0x21, vicii.regs[addr]));
1255
 
        return vicii.regs[addr] | 0xf0;
 
1735
        return vicii.viciidtv?vicii.regs[addr]:(vicii.regs[addr] | 0xf0);
1256
1736
 
1257
1737
      case 0x25:                  /* $D025: Sprite multicolor register #0 */
1258
1738
      case 0x26:                  /* $D026: Sprite multicolor register #1 */
1299
1779
      case 0x33:                  /* $D033: Unused */
1300
1780
      case 0x34:                  /* $D034: Unused */
1301
1781
      case 0x35:                  /* $D035: Unused */
1302
 
      case 0x36:                  /* $D036: Unused */
1303
 
      case 0x37:                  /* $D037: Unused */
1304
 
      case 0x38:                  /* $D038: Unused */
1305
 
      case 0x39:                  /* $D039: Unused */
1306
 
      case 0x3a:                  /* $D03A: Unused */
1307
 
      case 0x3b:                  /* $D03B: Unused */
1308
 
      case 0x3c:                  /* $D03C: Unused */
1309
 
      case 0x3d:                  /* $D03D: Unused */
 
1782
        return 0xff;
 
1783
 
 
1784
      case 0x36:                  /* $D036: Color Bank Low */
 
1785
        if (vicii.viciidtv) {
 
1786
            VICII_DEBUG_REGISTER(("Color Bank Low: $%02X",
 
1787
                                 vicii.regs[addr]));
 
1788
        }
 
1789
        return 0xff; 
 
1790
 
 
1791
      case 0x37:                  /* $D037: Color Bank High */
 
1792
        if (vicii.viciidtv) {
 
1793
            VICII_DEBUG_REGISTER(("Color Bank High: $%02X",
 
1794
                                 vicii.regs[addr]));
 
1795
        }
 
1796
        return 0xff;
 
1797
 
 
1798
      case 0x38:                  /* $D038: Linear Count A Modulo Low */
 
1799
        if (vicii.viciidtv) {
 
1800
            VICII_DEBUG_REGISTER(("Linear Count A Modulo Low: $%02X",
 
1801
                                 vicii.regs[addr]));
 
1802
        }
 
1803
        return 0xff;
 
1804
 
 
1805
      case 0x39:                  /* $D039: Linear Count A Modulo High */
 
1806
        if (vicii.viciidtv) {
 
1807
            VICII_DEBUG_REGISTER(("Linear Count A Modulo High: $%02X",
 
1808
                                 vicii.regs[addr]));
 
1809
        }
 
1810
        return 0xff;
 
1811
 
 
1812
      case 0x3a:                  /* $D03a: Linear Count A Start Low */
 
1813
        if (vicii.viciidtv) {
 
1814
            VICII_DEBUG_REGISTER(("Linear Count A Start Low: $%02X",
 
1815
                                 vicii.regs[addr]));
 
1816
        }
 
1817
        return 0xff;
 
1818
 
 
1819
      case 0x3b:                  /* $D03B: Linear Count A Start Middle */
 
1820
        if (vicii.viciidtv) {
 
1821
            VICII_DEBUG_REGISTER(("Linear Count A Start Middle: $%02X",
 
1822
                                 vicii.regs[addr]));
 
1823
        }
 
1824
        return 0xff;
 
1825
 
 
1826
      case 0x3c:                  /* $D03C: VICIIDTV register 1 */
 
1827
        if (vicii.viciidtv) {
 
1828
            VICII_DEBUG_REGISTER(("VICIIDTV register 1: $%02X",
 
1829
                                 vicii.regs[addr]));
 
1830
        }
 
1831
        return 0xff;
 
1832
 
 
1833
      case 0x3d:                  /* $D03D: Graphics fetch bank */
 
1834
        if (vicii.viciidtv) {
 
1835
            VICII_DEBUG_REGISTER(("Graphics fetch bank: $%02X",
 
1836
                                 vicii.regs[addr]));
 
1837
        }
 
1838
        return 0xff;
 
1839
 
1310
1840
      case 0x3e:                  /* $D03E: Unused */
1311
 
      case 0x3f:                  /* $D03F: Unused */
 
1841
        return 0xff;
 
1842
 
 
1843
      case 0x3f:                  /* $D03F: Enable extended features register */
 
1844
        if (vicii.viciidtv) {
 
1845
            VICII_DEBUG_REGISTER(("Enable extended features: $%02X",
 
1846
                                 vicii.regs[addr]));
 
1847
        }
 
1848
        return 0xff;
 
1849
 
 
1850
      case 0x40:                  /* $D040: VICIIDTV register 2 */
 
1851
        VICII_DEBUG_REGISTER(("VICIIDTV register 2: $%02X",
 
1852
                             vicii.regs[addr]));
 
1853
        return 0xff;
 
1854
 
 
1855
      case 0x41:                  /* $D041: Burst rate modulus high */
 
1856
        VICII_DEBUG_REGISTER(("Burst rate modulus high: $%02X",
 
1857
                             vicii.regs[addr]));
 
1858
        return 0xff;
 
1859
 
 
1860
      case 0x42:                  /* $D042: Burst rate modulus middle */
 
1861
        VICII_DEBUG_REGISTER(("Burst rate modulus middle: $%02X",
 
1862
                             vicii.regs[addr]));
 
1863
        return 0xff;
 
1864
 
 
1865
      case 0x43:                  /* $D043: Burst rate modulus low */
 
1866
        VICII_DEBUG_REGISTER(("Burst rate modulus low: $%02X",
 
1867
                             vicii.regs[addr]));
 
1868
        return 0xff;
 
1869
 
 
1870
      case 0x44:                  /* $D044: CPU cycle/IRQ trigger cycle */
 
1871
        VICII_DEBUG_REGISTER(("CPU cycle/IRQ trigger cycle: $%02X",
 
1872
                             vicii.regs[addr]));
 
1873
        return d044_read();
 
1874
 
 
1875
      case 0x45:                  /* $D045: Linear Count A Start High */
 
1876
        VICII_DEBUG_REGISTER(("Linear Count A Start High: $%02X",
 
1877
                             vicii.regs[addr]));
 
1878
        return 0xff;
 
1879
 
 
1880
      case 0x46:                  /* $D046: Linear Count A Step */
 
1881
        VICII_DEBUG_REGISTER(("Linear Count A Step: $%02X",
 
1882
                             vicii.regs[addr]));
 
1883
        return 0xff;
 
1884
        
 
1885
      case 0x47:                  /* $D047: Linear Count B Modulo Low */
 
1886
        VICII_DEBUG_REGISTER(("Linear Count B Modulo Low: $%02X",
 
1887
                             vicii.regs[addr]));
 
1888
        return 0xff;
 
1889
 
 
1890
      case 0x48:                  /* $D048: Linear Count B Modulo High */
 
1891
        VICII_DEBUG_REGISTER(("Linear Count B Modulo High: $%02X",
 
1892
                             vicii.regs[addr]));
 
1893
        return 0xff;
 
1894
 
 
1895
      case 0x49:                  /* $D049: Linear Count B Start Low */
 
1896
        VICII_DEBUG_REGISTER(("Linear Count B Start Low: $%02X",
 
1897
                             vicii.regs[addr]));
 
1898
        return 0xff;
 
1899
 
 
1900
      case 0x4a:                  /* $D04A: Linear Count B Start Middle */
 
1901
        VICII_DEBUG_REGISTER(("Linear Count B Start Middle: $%02X",
 
1902
                             vicii.regs[addr]));
 
1903
        return 0xff;
 
1904
 
 
1905
      case 0x4b:                  /* $D04B: Linear Count B Start High */
 
1906
        VICII_DEBUG_REGISTER(("Linear Count B Start High: $%02X",
 
1907
                             vicii.regs[addr]));
 
1908
        return 0xff;
 
1909
 
 
1910
      case 0x4c:                  /* $D04C: Linear Count B Step */
 
1911
        VICII_DEBUG_REGISTER(("Linear Count B Step: $%02X",
 
1912
                             vicii.regs[addr]));
 
1913
        return 0xff;
 
1914
        
 
1915
      case 0x4d:                  /* $D04D: Sprite bank */
 
1916
        VICII_DEBUG_REGISTER(("Sprite bank: $%02X",
 
1917
                             vicii.regs[addr]));
 
1918
        return 0xff;
 
1919
 
 
1920
      case 0x4e:                  /* $D04E: Scan line timing adjust */
 
1921
        VICII_DEBUG_REGISTER(("Scan line timing adjust: $%02X",
 
1922
                             vicii.regs[addr]));
 
1923
        return 0xff;
 
1924
 
 
1925
      case 0x4f:                  /* $D04F: VICIIDTV register 3 */
 
1926
        VICII_DEBUG_REGISTER(("VICIIDTV register 3: $%02X",
 
1927
                             vicii.regs[addr]));
1312
1928
        return 0xff;
1313
1929
 
1314
1930
      default:
1327
1943
        if (vicii.regs[0x1a] & 0x1)
1328
1944
            return vicii.irq_status | 0xf1;
1329
1945
        else
1330
 
            return vicii.irq_status | 0x71;
 
1946
            return vicii.viciidtv?vicii.irq_status | ((vicii.irq_status & 0xf) ? 0xf1 : 0x71):vicii.irq_status | 0x71;
1331
1947
    } else {
1332
 
        return vicii.irq_status | 0x70;
 
1948
        return vicii.viciidtv?vicii.irq_status | ((vicii.irq_status & 0xf) ? 0xf0 : 0x70):vicii.irq_status | 0x70;
1333
1949
    }
1334
1950
 
1335
 
    return vicii.irq_status;
 
1951
    return vicii.viciidtv?vicii.irq_status | ((vicii.irq_status & 0xf) ? 0x80 : 0x00):vicii.irq_status;
1336
1952
}
1337
1953
 
1338
1954
BYTE REGPARM1 vicii_peek(WORD addr)
1339
1955
{
1340
 
    addr &= 0x3f;
 
1956
    if (!vicii.viciidtv) {
 
1957
        addr &= 0x3f;
 
1958
    } else {
 
1959
        addr &= 0x7f;
 
1960
    }
1341
1961
 
1342
1962
    switch (addr) {
1343
1963
      case 0x11:              /* $D011: video mode, Y scroll, 24/25 line mode
1361
1981
        else
1362
1982
            return /* vicii.regs[addr] | */ 0xff;
1363
1983
      default:
 
1984
        if (addr>0x4f) return 0xff;
1364
1985
        return vicii.regs[addr] | unused_bits_in_registers[addr];
1365
1986
    }
1366
1987
}