Hello, Guest the thread was called2.9k times and contains 30 replays

last post from M. J. at the

scroll asm routine need help

  • Hello coders,

    After a while (30 years) I am back to get into asm coding.

    You will find scroll routine. Just one line with smooth scroll, 1x2 char...

    But I have problem with music. It doesnt work so I turn it off.
    Also I put routine after space is pressed to display text, wait another press space and then to reset.

    But also something gone wrong...

    Some solution, advice with code, maybe something else... main.asm

  • You do not say what's wrong. Educated guess: You check if space is pressed, but never wait for it to be released. So the instant you skip out of the scroll you check for space again, and in most cases it will still be pressed.
    Add some loop to wait for space to be released:

    1. waitSpaceRelease
    2. lda $dc01
    3. and #$10
    4. beq waitSpaceRelease

    Regarding the music player, a) are you sure the player is placed at $1000 for init, $1003 to play?
    and b) the player init does not require a, x or y be set to specific values?
    Also, the !binary pseudo op from ACME and C64Studio has the second(!) argument as number of bytes to skip. You probably meant !binary "music.bin",,2

    And more: You had a .sid file there. If that's a sid file like ChipAmp takes, there is a header in front, 27 bytes IIRC right. You need to add that to the number of bytes to skip from the offset.

  • Goodie :)

    I've put the wait code in there (waitspacerelease and waitspacerelease2)

    You might want to reset the hscroll and 39 column register for the second part, as the text may be clipped by the border.

  • 1.) Turn the addition into an INC

    1. inc gettext + 1
    2. bne gettext
    3. inc gettext + 2
    4. gettext:

    2.) Use a post-increment approach, i.e. get the byte first, then increment:

    3.) Use ORA instead of ADC #$80

    1. + sta $0427
    2. ora #$80
    3. sta $044f

    4.) In your special case you can speed up scrolling by using ORA #$80 instead of loading the value from line 2:

    1. - lda $0401, x
    2. sta $0400, x
    3. ora #$80
    4. sta $0428, x

    5.) Rearrange the interrupts. Currently you have the first interrupt running at line 0 for text scrolling and music, and another interrupt at line 50 for setting d016. As a result you are
    a) going to scroll the whole screen via $d016, not just the two upper lines,
    b) running into a possible race condition problem if the first interrupt at line 0 takes too long.
    You usually would want to set up your interrupt like this:
    line #50: switch on $d016 scrolling
    line #50 + 16: switch off $d016, scroll text if necessary and play music.
    As a rule of thumb: Scroll text after displaying the scrolling area has finished, not before.
    6.) Avoid storing and restoring X and Y if possible:

    7.) Try avoiding "DEC $d019" for acknowledging a VIC-irq. Use "LDA #1: STA $d019" instead. It's equally fast and only two bytes more, but prevents problems with a C64 not running on the bullt-in 6502.

  • Well, that is fine solution.
    I never thought that is necessary to put routine for released space (or any key whatever).

    But know there is problem with displaying text (its only part of text visible). You mentioned something about that in previously post.

    Solution ?

    If I wanna put the bottom scroller is it enough to get the right position on the screen (and in case to use different charset?).

    Lot of questions...

    But I am hungry of c64 code

  • Did you use to be part of the oldschool scene from mid of eighties?

    Uh, well, you know, in those days[tm] I used to program the C64 a lot, and I still do, but I have never been part of any scene. BTW in the forum you will find a lot of people more experienced than me, for example Endurion. So in case you got stuck, feel free to ask for help.
    Just one more thing: How about dividing your program into subroutines, e.g. one subroutine for clearing the screen, one subroutine for waiting for <space>, like:

    You can call these twice and then drop the "JSR $E544 ;QUICK SCREEN CLEAR".

  • Well,

    First, I tried with music routine: but it doesnt work (I used p2s for convert prg music to sid music and to relocate from xxxx position to $1000 and $1003)

    If I put font to $3000 I got empty Black screen.

    Second, I used for restore 38 to 40 colmuns code:

    LDA $D016 ; read value of $D016 to register A
    ORA #8 ; #8 = %00001000 (binary) set 3rd bit
    STA $D016 ; store A back to $D016

    I put it after waitpressedspace2
    But without effect.

    Solution?main 2.asmbrandenburg.sid

  • Regarding $d016, you also need to reset the horizontal scroll offset, I'll do a brutal

    ;correct h scroll register
    lda #$08
    sta $D016

    Regarding the music, the SID file doesn't seem to play anything if I let WinAMP with SID-Plugin at it. Could be the relocation broke it?

    Edit: Sch****dreckk*ck message editor, stop f*cking swalling line breaks!

  • :D Don't let Bytebreaker pull your leg. Listen to Endurion. He's the expert you need.

    If I put some other position of screen text 0525,x the text is still half visible.

    Could you please specify what you mean by "half visible"? Or even better: Could you post a screenshot from an emulator (like WinVice)?

    Just two more things:
    1.) The file "brandenburg.sid" is corrupt. It does not contain any program code at all.There is no way you can use this file in your program on its own.
    2.) Avoid using rom routines like $e544.
    a) Rom routines are usually very, very slow.
    b) They use variables on the zeropage and elsewhere in memory, which can result in unwanted side-effects. For example: $e544 clears the screen using the colour byte found at address $286. If this address was set to 0 beforehand by some other code, all you get is a dark screen as the colour ram at $d800 will be filled with 0.
    Use rom routines only when absolutely necessary e.g. loading data from disk via Kernal.

  • Uhm, you haven't forgotten that you use a special font of size 1x2, have you? If you still want to use this font for displaying the final message, you must poke the upper and the lower half into text memory like you did with the scroller:

    1. ldx #$00
    2. txtloop: lda txt, x
    3. beq waitspace2
    4. sta $0400, x
    5. ora #$80 ; <- add these
    6. sta $0428, x ; <- two lines
    7. inx
    8. jmp txtloop