数学研究室

2292 ワード


こんにちは、私の友人.このブログはSPO 666の第3研究室です.この研究室では、6502アセンブリ言語を使用して卓球ゲームを作成する予定です.
これは今までの作品です.私が実験室を終えたときにアップロードします.
define POINTER $10
define POINTER_H $11
define POSITION $30
define ROW $20 ; current row
define COL $21 ; current column

; constants
define DOT $01 ; dot colour
define PADDLE $01 ; paddle colour

setup: lda #$0f ; set initial ROW,COL
sta ROW
lda #$0F
sta COL
lda #$20
LDA #05
STA POSITION

draw: lda ROW ; ensure ROW is in range 031
and #$1f
sta ROW

lda COL ; ensure COL is in range 031
and #$1f
sta COL

ldy ROW ; load POINTER with start-of-row
lda table_low,y
sta POINTER
lda table_high,y
sta POINTER_H

ldy COL ; store CURSOR at POINTER plus COL
lda #DOT
sta (POINTER),y




;SET A PROINTER TO THE BOTTOM-LEFT CORNER
LDA #$EC
STA POINTER
LDA #$05
STA POINTER_H

; STORE THE POSITION TO THE POINTER
LDA POINTER
CLC
ADC POSITION
STA POINTER

LDA #$01
LDY #$00
loop:
STA (POINTER),Y
INY
CPY #$07
BNE loop

getkey:lda $ff ; get a keystroke

ldx #$00 ; clear out the key buffer
stx $ff

cmp #$43 ; handle C or c
beq clear
cmp #$63
beq clear

cmp #$80 ; if not a cursor key, ignore
bmi getkey
cmp #$84
bpl getkey

;pha ; save A

;lda #POSITION ; set current position to POINTER
;sta (POINTER),y

;pla ; restore A

cmp #$81 ; check key == RIGHT
bne checkL

inc POSITION ; ... if yes, increment POSITION
jmp done



checkL: cmp #$83 ; check key == left
bne done

dec POSITION ; ... if yes, decrement POSITION
clc
bcc done

clear: lda table_low ; clear the screen
sta POINTER
lda table_high
sta POINTER_H

ldy #$00
tya




c_loop: sta (POINTER),y
iny
bne c_loop

inc POINTER_H
ldx POINTER_H
cpx #$06
bne c_loop



done: clc ; repeat
jmp draw

; these two tables contain the high and low bytes
; of the addresses of the start of each row
table_high:
dcb $02,$02,$02,$02,$02,$02,$02,$02
dcb $03,$03,$03,$03,$03,$03,$03,$03
dcb $04,$04,$04,$04,$04,$04,$04,$04
dcb $05,$05,$05,$05,$05,$05,$05,$05,

table_low:
dcb $00,$20,$40,$60,$80,$a0,$c0,$e0
dcb $00,$20,$40,$60,$80,$a0,$c0,$e0
dcb $00,$20,$40,$60,$80,$a0,$c0,$e0
dcb $00,$20,$40,$60,$80,$a0,$c0,$e0