Hallo Besucher, der Thread wurde 1,4k mal aufgerufen und enthält 5 Antworten

letzter Beitrag von simun9 am

c64 asm coding text on the screen

  • Hi there,


    After a while (one year) I finnallz found time for learning of asm coding to beloved c64.


    I decided to pay attention to M.J. advice and to try to understand whats going on with every line of code.


    So I started with put text on the screen and $d018.


    It consists of three lines of text (different postion on the screen with different fonts and colours aand native 1x1 fonts size).


    Now I wanna use ie. 2x2 font for the second line of the text. I know I have to expand chars to be 16x16 so it would be two lines of text. Whats next ?


    I ve just read about opening borders (side and top-bottom) but i didnt understand in depth.


    How to put some efects to the lines: fade in out, colourwash etc.

  • Just some hints:


    1.) Initialise the highest bit of the raster interrupt (Bit #7 in $d011) only once in the main program, not during the interrupt. This saves time and possibe glitches. (You would have to set the other bits of $d011 to their corresponding values not just to zero.)
    2.) Instead of "CLC:ADC #$40" you can simply use "ORA #$40" as the two highest bits (#7 and #6) should be zero.
    3.) The program as presented in "main (4).asm" won't run properly, since the interrupt service routines do not end in RTI. (You have outcommted the jump to $ea7e, and the the routine ends in "jmp MainLoop".

    2x2 font for the second line of the text.

    The easiest way to create a 2x2 font display is to divide the 256 character set into 4 groups.
    1) Arrange the groups from 0..63, 64..127, 128..191 and 192..255. The first group contains the upper left part of 64 different characters, the second group the upper right, followed by the third group "lower left" and fourth "lower right". Plotting a 2x2 Char is then done by poking four values:

    Code
    1. lda text, x
    2. sta $400, y ; upper left
    3. ora #$40
    4. sta $401, y ; upper right
    5. eor #$c0
    6. sta $428, y ; lower left
    7. ora #$40
    8. sta $429, y ; lower right

    2.) Or arrange the groups by multiplying the character code by 4. This way code * 4 contains the upper left, code * 4 + 1 contains the upper right, code * 4 + 2 contains the lower left, and code * 4 + 3 contains the lower right. The code then looks like:

    Code
    1. lda text, x
    2. asl
    3. asl
    4. sta $400, y ; upper left
    5. ora #1
    6. sta $401, y ; upper right
    7. eor #3
    8. sta $428, y ; lower left
    9. ora #1
    10. sta $429, y ; lower right
  • The first part of code is my attempt to deal with raster interrupt. But as I said it just beginning of my learning so I used some old routines just as example to see what it should do.


    So the real code starts from clear screen routine.


    according to the hints:


    1. Thank you I should have it on my mind later on when I start with interrupts


    2. Which is the best way for use (I thnik I should listen to your advice when I use more complex sort of code but maybe at this level of code I can leave as it was written) ?


    3. I think it should run if you read my comments above or ?


    For 2x2 fonts:


    I meant to use some 2x2 fonts from the net. So should I use the code you mentioned in the last comment or I have to expand matrix 8x8 and point it to the bin file of 2x2 font ?


    Maybe some advice for effects fade in colourwash and rolling chars...

  • So, part for 2x2 font should be like this:


    Using any 2x2 font (load with !bin) ;
    We need to draw those in screen...
    clc
    ldx #$00
    ldy #$00
    .loop lda second_line,x ; second line of text (value supposedly in range $00-$3f)
    sta $04C8,y ; set top left 8x8 pixel block of 2x2 font
    adc #$40 ; adjust value (to range $40-$7f by adding #$40)
    sta $04c9,y ; set top right 8x8 pixel block of 2x2 font adc #$40 ; adjust value (to range $80-$Bf by adding #$40 again)
    sta $04f0,y ; set bottom left 8x8 pixel block of 2x2 font adc #$40 ; adjust value (to range $C0-$ff by adding #$40 again)
    sta $04f1,y ; set bottom right 8x8 pixel block of 2x2 font
    inx ; increment text read offset
    iny ; increment screen draw offset
    iny ; twice because 2x2 fonts
    cpy #$28 bne
    .loop
    We can imagine 2x2 font like:
    12
    34


    Nr. 1 range: $00-$3fNr. 2 range: $40-$7fNr. 3 range: $80-$bfNr. 4 range: $C0-$ff


    For any letter as 2x2 font we have 8x8 cels x 4 which gives 256.


    Please let me know is this right way of thinking about how to display 2x2 fonts.

  • Seems fine to me so far. Have you tried it?
    BTW.: You can avoid trouble with the carry-flag here by using ORA and EOR instead of ADC. You may also want to use the code-tags (s. "</>") when inserting code in your post so your code won't get garbled.

  • I tried it. And it works.


    But now I decided to go on with first attempt of intro coding.
    Ive read lot of docs on the net and with great support of ex--scener coder I wil try following:


    Raster bars with colours and moving, logo, three lines of text and music.
    It will be well commented as I need it for myself.


    In case of some issues probably will ask here also.