0

Z80 汇编语言的第一步之后,我试图在汇编程序中移动两个高字符精灵。

            ORG 30000         ; Origin

LASTK       EQU 23560         ; last key press (system variable)

PRINT       EQU 8252          ; This means the label PRINT equates to 8252.


            XOR a             ; quick way to load accumulator with zero.
            LD A, 2           ; set print channel to screen

            CALL 5633         ; Open channel two (ie, write to screen)
            LD HL, GFX        ; set up UDGs
            LD (23675), HL    ; where the UDG characters are stored.
            CALL 3503         ; clear the screen. CLS


MAINLP      CALL PRTPLAY      ; print player sprite
            
            HALT              ; Slow it down three times
            HALT
            HALT

            LD BC, $FEFE      ; load port address into BC, scan for right ("X")
            IN A, (C)         ; load port data into A
            AND %0000100      ; looking for X
            JR Z, GORIGHT     ; if Z is press, go right

            JR MAINLP         ; loop back to continue scanning


GORIGHT     LD A, (PLAYER+2)  ; if player is at right edge, don't continue
            CP 31
            JR Z, MAINLP      ; Jump Relative Zero
            CALL UNDRAW
            LD A, (PLAYER+2)  ; get player's X coordinate
            INC A             ; add 1
            LD (PLAYER+2), A
            JR MAINLP


PRTPLAY     LD DE, PLAYER           ; print player graphic
            LD BC, EOPLAYR-PLAYER
            CALL PRINT
            RET


UNDRAW      LD A, " "            ; change graphic to empty space
            LD (PLAYER+3), A     ; store it
            CALL PRTPLAY         ; undraw graphic from screen
            LD A, 144            ; change graphic back to normal
            LD (PLAYER+3), A     ; store it


            RET ; return to basic!

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

            ; Player x, y 
PLAYER      DEFB 22, 12, 15, 144 ; print at Y, X, char 144 UDG (A)
            DEFB 22, 13, 15, 145 ; print at Y+1, X, char 145 UDG (B)
            EOPLAYR EQU $

            ; Graphics UDG Character
GFX         DEFB 6, 62, 124, 52, 62, 60, 24, 60
            DEFB 126, 126, 247, 251, 60, 118, 110, 119
            

Manic Miner sprite 绘制正常。然而,当按下“x”向右移动时,只有上半部分移动。这要么意味着未绘制不起作用,要么底部字符没有增加。我对汇编程序很陌生,并试图找出我出错的地方。我怀疑这是明确告诉 DEFB 在 144 和 145 上的地方,但撤消仅在 144 上。然而,这应该由 LD BC, EOPLAYR-PLAYER 涵盖。使困惑。

4

0 回答 0