Hallo Besucher, der Thread wurde 1,2k mal aufgerufen und enthält 9 Antworten

letzter Beitrag von DutchGuy am

Konvertierung des Zeichenbildschirms X Y in Sprite X Y-Koordinaten

  • Ist dies auf einfache Art und Weise möglich?

    Ich hatte daran gedacht, die x- und y-Koordinaten eines Zeichens auf dem Bildschirm mit hilfe ASL ASL ASL mit 8 zu multiplizieren, um die X- und Y-Koordinaten für mein Sprite zu erhalten, aber es funktioniert nicht. Wo denke ich falsch? ?(

  • Das Ergebnis in meinem Programm. Ich musste an etwas feilen, um es genau zu bekommen. Wenn jemand einen Kommentar dazu hat, würde ich ihn gerne hören. Ich brauche sehr oft CLC, vielleicht könnte das klüger sein?

    ;*******************************************************************************

    SpriteToCharXY

    ; Calc X en Y Sprite RabX en RabY tot Char X en Char Y

    ; X, Y en A not saved

    ; Output CharX in X en Char Y in Y


    LDA RabX

    CLC

    SBC #24 ; delete offset X now a correct X

    CLC

    ROR ; devide by 8

    CLC

    ROR

    CLC

    ROR

    TAX ; should be X position of Char screen

    INX

    INX


    LDA RabY

    CLC

    SBC #50 ; delete offset now a correct Y

    CLC

    ROR ; devide by 8

    CLC

    ROR

    CLC

    ROR

    TAY ; should be Y position of Char screen


    RTS

    ;*******************************************************************************

  • Wie Jens schon schrieb: wenn du 24 subtrahieren möchtest, musst du vorher SEC setzen. Genauso bei der 50 für die Y-Position.

  • @JensLtb "wenn man es nicht setzt, wird quasi eins mehr abgezogen ...". Ich denke nicht das das richtig ist:


    Von eind buch ich habe gefunden mit google: "MACHINE LANGUAGE ROUTINES FOR THE COMMODORE 64/128 Todd D. Heimarck and Patrick Parnsh":

    ---------------------------------------------------------------------------------------------------

    The rule to remember is always to clear the carry flag (CLC) before addition and always to set the carry flag (SEC) before subtraction.

    If you're subtracting large numbers (two bytes or more), set carry before subtracting the least significant byte. As larger numbers are subtracted, carry will take care of itself.

    Subtracting a large number from a smaller number (5 - 20, for example) will result in a cleared carry. If the second number is smaller than the first, carry will remain set.

    If .A is greater than or equal to the value subtracted, the result is positive, and C is set.

    The result of the subtraction is found in the accumulator;

    ---------------------------------------------------------------------------------------------------

    Oder verstehe ich dieses nicht genau richtig?

  • @JensLtb: Sie haben Recht. Ich entschuldige mich.

    Von ein anderes Buch : "ASSEMBLY LANGUAGE PROGRAMMING with the Commodore 64 Marvin L DeJong":

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    VI. The SBC Instruction

    The carry flag, C, is also used in the subtraction instruction, but in a more subtle way than you might expect. The carry flag can have two values, zero

    or one. The complement of the carry flag, designated by ¬C has the binary value opposite to that found in the carry flag. Thus, if C = 1 then ¬C= 0, and if C = 0 then ¬C = 1. It may be helpful to think of the complement of the carry flag as a borrow flag, although you should be aware that there is not a borrow flag in the P register.


    We are now ready to define the SBC instruction:

    • The SBC instruction subtracts the number M in a memory location from the number A in the accumulator. The complement of the carry flag, ¬C, is also subtracted from

    the number in the accumulator. The result is stored in the accumulator.

    • Symbolically, the SBC instruction is written A = A - M - ¬C where M and A are eight-bit numbers and ¬C is a one-bit number.

    • After execution of the SBC instruction, the carry flag will be cleared (indicating a borrow) if a larger number is subtracted from a smaller; otherwise, it will be set.


    You can see from this definition that if the carry flag is set after a subtraction, no borrow was required. If the carry flag is cleared after a subtraction,

    the need to borrow is indicated.

    You can also see that if you are subtracting two eight-bit numbers with the SBC instruction, the carry flag should be set before subtracting.

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Ich habe heute was gelernt :)