Menu

#988 CRTC emulation is incomplete

v3.6
open
crtc (1)
CRTC
2025-11-22
2018-02-28
Michau
No

The CRTC chip emulation in the CBM-II is incomplete:

  • Esc+U is supposed to change the cursor to underscore, but it has no effect. It appears that the cursor shape registeres in the CRTC are not emulated.
  • Esc+Z is supposed to switch to alternate character set, but is has no effect. It appears that the emulator only acceps 4 kB character ROMs, whereas the original CBM-II has an 8 kB character ROM where the uppor part contains an alternate character set.

Discussion

  • Stefan Haubenthal

    Our chargen.600 and chargen.700 are 4 KB, can you append a dump?

     
  • gpz

    gpz - 2018-03-05

    that would be helpful, indeed

     
  • Michau

    Michau - 2018-03-06

    Sure, here is my ROM.

     
  • gpz

    gpz - 2018-03-12

    some observations so far:

    our chargen.500 is 4kb and it is the same as the C64 chargen. that makes sense :)

    now our chargen.700 is the same as the first half of your charset.bin - as expected. there is indeed funky code in cbm2rom.c - it loads those 4k, and then generates an inverted copy of this data in the next 4k. i have quickly hacked this function to load the full 8k, but apparently this doesnt really change anything. its a bit annoying to test here right now because the keyboard maps are also broken and need to be fixed :)

    questions:

    should the charset really change immediatly when pressing ESC+Z (at once?)? and on the entire screen? what are chars that would actually be different?

    to track it down further i'd like to know how this reverse mode and alternative charset implemented on the hardware side of things, is it a CRTC feature? or some simply switch on an address line of the ROM?

    i could find some references to the cursor shape stuff, and it indeed looks incomplete

    edit: ok, i am getting far enough to see debug printfs when pressing ESC+Z/ESC+Y - it toggles bit 4 or CRTC register 12.

    as far as i can see, large parts of the emulation are incomplete though, it will be a bit of work to add this without breaking things

    as a first step i'd like to fix the keyboard maps a bit, and have the emu load the proper ROMs - do you have the complete chargen for C600 series too?

     

    Last edit: gpz 2018-03-12
  • Stefan Haubenthal

    BTW the C128 is also missing Esc+U (shares the same source code).
    Maybe Esc+Z is something like this ASCII/DIN key? Hint: data/C128/charg??

     
  • Michau

    Michau - 2018-03-12

    Yes, I presume this is some kind of DIN character set switch.

    WRT the questions:

    1. Yes, the character set should change immediately on the whole screen, similarly to what happens when you press C= + Shift on the C64. The font ROM I sent you is the PC emulator font; you can see the difference for example in the yhe <- (left arrow character) - in the alternate font it should turn to _ (underscore).

    2. Reverse mode and alternate charset are done by setting high address lines in the CRTC. From the schematic I can see that screen reverse is set by changing A12 and alternate charset by changing A11.

    3. You can of course trigger this behaviour from BASIC: PRINT CHR$(27);"Z"l is the equivalent of pressing Esc+Z.

    4. I don't have a chargen from the 610 at the moment, but I can go and look.

     
  • Michau

    Michau - 2018-03-12

    Here is a 610 Hungarian character set that I downloaded from Zimmers. It has something in the upper 4 kB.

    Generally, a standard (non-nationalized) characters ROM for 610/710 is 8 kB in size and has FF's in the upper 4 kB. Nationalized and/or special character sets will have the upper 4 kB populated with another character set.

    So I think for starters, you should expand your "chargen.600" and "chargen.700" to 8 kB by padding with FF, because that's what in the real machine.

    The code that loads 4 kB and inverts it for another 4 kB makes sense to me - it simulates inverse which (contrary to 64 and P500) is done in hardware, using 7th bit from the screen RAM. So quickly loading the rest of the font into the upper 4 kB will not work (you will just see alternate characters instead of reverse characters), if this reverse trick must be continued then the buffer bust be expanded to 16 kB (8 kB ROM plus 8 kB inverted).

     
  • gpz

    gpz - 2018-03-15

    looking further at the code a bit... one thing i'd like to know before i start changing how it works would be if this inverting is purely a CRTC feature, or if there is some logic on the board that makes the CRTC "see" inverted data every 2k. if the later is the case, i could kinda live with the current implementation, however if its a pure crtc feature, then it should be implemented as such in the CRTC emulation

    edit: ok, no mention of inverse-video in the 6545 datasheet at all - so i guess there IS some funky logic on the board that does this? :)

     

    Last edit: gpz 2018-03-15
  • gpz

    gpz - 2018-03-15

    ok... ESC-Z/Y should be fixed in r34561 - please test again

     
  • gpz

    gpz - 2021-10-26
    • Category: xcbm2 --> CRTC
     
  • gpz

    gpz - 2025-11-03
    • assigned_to: Olaf Seibert
     
  • Olaf Seibert

    Olaf Seibert - 2025-11-22

    If it is like on the PET, then there is logic on the board to pass the high bit of the byte that was fetched from the screen memory, and feed it into a XOR that inverts the pixels of the character before it is sent to the screen.

    However the implementation in VICE pretends that there is actually a larger character ROM present, with the inverted chars in the second half.

    I think the changes that gpz made in r34561 seem to work for both cases.

    I tested this:

    Start with gtk3-xcbm2 -model 710 --chargen charset.bin

    *** commodore basic 128, v4.0 ***
    
    
    ready.
    for i=32 to 95:?chr$(i)chr$(i+128);:next
     ?!A"B#C$D%E&F'G(H)I*J+K,L-M.N/O0P1Q2R3S4T5U6V7W8X9Y:Z;?<?=?>???@?aAbBcCdDeEfFgG
    hHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ[?\?]?^?_?
    ready.
    

    With all chars on the screen:
    esc z changes some of the characters
    esc y changes them back
    esc u makes an underline cursor
    esc s makes a solid cursor
    esc r reverses (inverts) the whole screen
    esc n makes it normal again.

    Same test with gtk3-xcbm2 -model 610 --chargen characters-hungarian.bin.
    Is it expected that the localized character set is default? See the first attached screen shot (I doubled it vertically to correct the aspect ratio)

     

    Last edit: Olaf Seibert 2025-11-22

Log in to post a comment.

MongoDB Logo MongoDB