417 lines
4.6 KiB
Plaintext
417 lines
4.6 KiB
Plaintext
.main:
|
|
brn .start
|
|
.p1_x: 0x0035 ;50
|
|
.p1_y: 0x0030 ;fila 20
|
|
.p2_x: 0x0070
|
|
.p2_y: 0x0030
|
|
.ball_x: 0x0040 ;fila 20 + 100
|
|
.ball_y: 0x0035 ;fila 20 + 100
|
|
.ball_dir: 0x0000
|
|
.ball_y_dir: 0x0000
|
|
.patt: 0x0000
|
|
|
|
.start:
|
|
call .clear
|
|
call .mov_ball
|
|
call .mov_players
|
|
call .col_ball
|
|
call .bounce_ball
|
|
call .draw
|
|
brn .start
|
|
|
|
.bien:
|
|
brn .bien
|
|
|
|
.draw:
|
|
lit_n 0xcaba
|
|
lit_n .p1_x
|
|
load
|
|
lit_n .p1_y
|
|
load
|
|
lit_n 0x00c8
|
|
mul 0x0000
|
|
call .draw_p
|
|
|
|
lit_n 0xacab
|
|
lit_n .p2_x
|
|
load
|
|
lit_n .p2_y
|
|
load
|
|
lit_n 0x00c8
|
|
mul 0x0000
|
|
call .draw_p
|
|
lit_n 0xeeee ;ball colour
|
|
call .draw_ball
|
|
ret
|
|
|
|
.bounce_ball:
|
|
lit_n .ball_y
|
|
load
|
|
lit_n 0x0020
|
|
bgt .inv_d
|
|
pop
|
|
l_store 0x0000
|
|
lit_n 0x0070
|
|
l_load 0x0000
|
|
bgt .inv_u
|
|
pop
|
|
pop
|
|
ret
|
|
.inv_d:
|
|
pop
|
|
pop
|
|
lit_n 0x0001
|
|
lit_n .ball_y_dir
|
|
store
|
|
ret
|
|
.inv_u:
|
|
pop
|
|
pop
|
|
lit_n 0x0000
|
|
lit_n .ball_y_dir
|
|
store
|
|
ret
|
|
|
|
.draw_ball:
|
|
lit_n .ball_x ;*ball
|
|
load ;deref
|
|
lit_n .ball_y
|
|
load
|
|
lit_n 0x00c8
|
|
mul
|
|
add
|
|
store ;ball <- = colour
|
|
ret
|
|
|
|
;Toma dos argumentos: x, y
|
|
;Dibuja en esa posicion un rect
|
|
;De tamaño 2*10
|
|
.draw_p:
|
|
l_store 0x0000 ;y
|
|
l_store 0x0004 ;x
|
|
l_store 0x0010 ;color
|
|
|
|
lit_n 0x0000 ;player size
|
|
l_store 0x000c ;i
|
|
|
|
._draw_p_loop:
|
|
l_load 0x0000 ;h = y
|
|
l_load 0x000c ;h = i
|
|
lit_n 0x00c8 ;h = 200
|
|
mul 0x0000
|
|
add ;h = y + i * 200
|
|
l_load 0x0004 ;h = x
|
|
add ;h = x + y + i * 200
|
|
l_store 0x0008 ;swp
|
|
l_load 0x0010 ;load color
|
|
l_load 0x0008 ;h = x + y + i * 200
|
|
store ;x + y + i * 200 <- 10
|
|
|
|
l_load 0x000c ;h = i
|
|
lit_n 0x000a ;h = 0
|
|
beq ._draw_p_end ;i == 0 => end
|
|
pop ;i != 0 => i - 1; loop
|
|
;pop 0 => h = i
|
|
|
|
l_store 0x0014
|
|
lit_n 0x0001
|
|
l_load 0x0014
|
|
add ;h = i - 1
|
|
|
|
l_store 0x000c ;pop head
|
|
brn ._draw_p_loop
|
|
._draw_p_end:
|
|
pop
|
|
pop
|
|
ret
|
|
|
|
|
|
.mov_ball:
|
|
lit_n 0x0001
|
|
lit_n .ball_x
|
|
load
|
|
lit_n .ball_dir
|
|
load
|
|
lit_n 0x0000
|
|
beq .b_left
|
|
pop
|
|
pop
|
|
add
|
|
brn .b_apply
|
|
.b_left:
|
|
pop
|
|
pop
|
|
sub
|
|
brn .b_apply
|
|
.b_apply:
|
|
lit_n .ball_x
|
|
store
|
|
|
|
lit_n 0x0001
|
|
lit_n .ball_y
|
|
load
|
|
|
|
lit_n .ball_y_dir
|
|
load
|
|
lit_n 0x0000
|
|
beq .b_up
|
|
.b_down:
|
|
pop
|
|
pop
|
|
add
|
|
brn .b_y_apply
|
|
.b_up:
|
|
pop
|
|
pop
|
|
sub
|
|
brn .b_y_apply
|
|
.b_y_apply:
|
|
lit_n .ball_y
|
|
store
|
|
ret
|
|
|
|
.mov_players:
|
|
lit_n 0x752b ;posicion de la tecla W
|
|
load
|
|
lit_n 0xffffffff
|
|
beq ._p1_up
|
|
pop
|
|
pop
|
|
lit_n 0x7527 ;posicion de la tecla S
|
|
load
|
|
lit_n 0xffff
|
|
beq ._p1_down
|
|
pop
|
|
pop
|
|
brn ._p2
|
|
._p1_down:
|
|
pop
|
|
pop
|
|
call .mov_p1_down
|
|
brn ._p2
|
|
._p1_up:
|
|
pop
|
|
pop
|
|
call .mov_p1_up
|
|
brn ._p2
|
|
._p2:
|
|
lit_n 0x7523 ;posicion de la tecla I
|
|
load
|
|
lit_n 0xffff
|
|
beq ._p2_up
|
|
pop
|
|
pop
|
|
lit_n 0x751f ;posicion de la tecla K
|
|
load
|
|
lit_n 0xffff
|
|
beq ._p2_down
|
|
pop
|
|
pop
|
|
brn ._mov_end
|
|
._p2_down:
|
|
pop
|
|
pop
|
|
call .mov_p2_down
|
|
brn ._mov_end
|
|
._p2_up:
|
|
pop
|
|
pop
|
|
call .mov_p2_up
|
|
brn ._mov_end
|
|
._mov_end:
|
|
ret
|
|
|
|
.mov_p1_up:
|
|
lit_n 0x0003
|
|
lit_n .p1_y
|
|
load
|
|
sub
|
|
lit_n .p1_y
|
|
store
|
|
ret
|
|
|
|
.mov_p1_down:
|
|
lit_n 0x0003
|
|
lit_n .p1_y
|
|
load
|
|
add
|
|
lit_n .p1_y
|
|
store
|
|
ret
|
|
|
|
.mov_p2_up:
|
|
lit_n 0x0003
|
|
lit_n .p2_y
|
|
load
|
|
sub
|
|
lit_n .p2_y
|
|
store
|
|
ret
|
|
|
|
.mov_p2_down:
|
|
lit_n 0x0003
|
|
lit_n .p2_y
|
|
load
|
|
add
|
|
lit_n .p2_y
|
|
store
|
|
ret
|
|
|
|
|
|
.clear:
|
|
call .clear_p
|
|
lit_n 0x0000
|
|
call .draw_ball
|
|
ret
|
|
|
|
.hang:
|
|
brn .hang
|
|
|
|
;Toma dos parametros y x
|
|
.clear_p:
|
|
lit_n 0x0000
|
|
lit_n .p1_x
|
|
load
|
|
lit_n .p1_y
|
|
load
|
|
lit_n 0x00c8
|
|
mul 0x0000
|
|
call .draw_p
|
|
lit_n 0x0000
|
|
lit_n .p2_x
|
|
load
|
|
lit_n .p2_y
|
|
load
|
|
lit_n 0x00c8
|
|
mul 0x0000
|
|
call .draw_p
|
|
ret
|
|
|
|
.col_ball:
|
|
lit_n .ball_x
|
|
load
|
|
lit_n .p1_x
|
|
load
|
|
bgt .chk_p1_bnc
|
|
pop
|
|
pop
|
|
lit_n .p2_x
|
|
load
|
|
lit_n .ball_x
|
|
load
|
|
bgt .chk_p2_bnc
|
|
pop
|
|
pop
|
|
ret
|
|
|
|
|
|
.hang:
|
|
brn .hang
|
|
|
|
.chk_p1_bnc: ;px > bx
|
|
pop
|
|
pop
|
|
lit_n .p1_y
|
|
load
|
|
lit_n .ball_y
|
|
load
|
|
bgt .chk_p1_y_bn
|
|
brn .no_p1_y_bn
|
|
|
|
.chk_p1_y_bn: ;by > py
|
|
sub
|
|
l_store 0x0000
|
|
lit_n 0x000a
|
|
l_load 0x0000
|
|
bgt .no_p1_y_bn
|
|
pop
|
|
pop
|
|
lit_n 0x0001
|
|
lit_n .ball_dir
|
|
store
|
|
ret
|
|
|
|
.no_p1_y_bn:
|
|
pop
|
|
pop
|
|
ret
|
|
|
|
.chk_p2_bnc: ;px > bx
|
|
pop
|
|
pop
|
|
lit_n .p2_y
|
|
load
|
|
lit_n .ball_y
|
|
load
|
|
bgt .chk_p2_y_bn
|
|
brn .no_p1_y_bn
|
|
|
|
.chk_p2_y_bn: ;by > py
|
|
sub
|
|
l_store 0x0000
|
|
lit_n 0x000a
|
|
l_load 0x0000
|
|
bgt .no_p1_y_bn
|
|
pop
|
|
pop
|
|
lit_n 0x0000
|
|
lit_n .ball_dir
|
|
store
|
|
ret
|
|
|
|
.invert_dir:
|
|
lit_n .patt
|
|
load
|
|
lit_n 0x0000
|
|
beq .patt1
|
|
pop
|
|
lit_n 0x0001
|
|
beq .patt2
|
|
pop
|
|
lit_n 0x0002
|
|
beq .patt3
|
|
pop
|
|
lit_n 0x0004
|
|
beq .patt4
|
|
pop
|
|
pop
|
|
lit_n 0x0000
|
|
lit_n .patt
|
|
store
|
|
lit_n 0x0000
|
|
lit_n .ball_y_dir
|
|
store
|
|
ret
|
|
|
|
.patt1:
|
|
lit_n 0x0001
|
|
lit_n .ball_y_dir
|
|
store
|
|
brn .inc_patt
|
|
.patt2:
|
|
lit_n 0x0001
|
|
lit_n .ball_y_dir
|
|
store
|
|
brn .inc_patt
|
|
.patt3:
|
|
lit_n 0x0000
|
|
lit_n .ball_y_dir
|
|
store
|
|
brn .inc_patt
|
|
.patt4:
|
|
lit_n 0x0001
|
|
lit_n .ball_y_dir
|
|
store
|
|
brn .inc_patt
|
|
|
|
.inc_patt:
|
|
lit_n .patt
|
|
load
|
|
lit_n 0x0001
|
|
add
|
|
lit_n .patt
|
|
store
|
|
pop
|
|
pop
|
|
ret
|