My point of view on this.
* = $4000
p1 = $d0
p2 = $d2
xpos = 1536
ypos = 1537
joystick = 1538
p0hpos = 1539
p0vpos = 1540
smlframe = 1541
frame = 1542
playcount = 1543
xpm2scn = 1544
ypm2scn = 1545
xpm = 1546
ypm = 1547
begin lda #<scr ; start by calculating look-up tables
sta p1 ; at the same time, we will clear the
lda #>scr ; screen
sta p1+1
ldx #0
c0 lda #0 ; draw a character
ldy #39 ; clear a single line
c1 ;sta (p1),y ; WRITES OVER SCREEN
dey
bpl c1
lda p1+1 ; store address into look-up table
sta schi,x
lda p1
sta sclo,x
clc ; update zero page to next line
adc #40 ; 40 bytes per line
sta p1
bcc c2
inc p1+1
c2 inx ; for all 24 lines...
cpx #24
bne c0
lda #4 ; set some colors
sta 708 ; make ANTIC4 slightly more readable
lda #6
sta 709
lda #8
sta 710
lda #<DLIST ; finally, point ANTIC to new display
sta 560
lda #>DLIST
sta 561
; Main loop
pmmover
lda #$80 ; reserve 8 pages
sta 54279 ; ... and in PMBASE
lda #32 ;
sta 623
lda #62 ; turn on DMACTL. 46 is single-resolution
sta 559
lda #3 ; turn on GRACTL
sta 53277
lda #16 ; single resolution players
sta 54272
lda #104 ;
sta 704 ; color players
lda #28
sta 705
lda #0
sta 710
; set up pm-to-screen
lda #0
sta smlframe
lda #48+4 ; starting position of pm. +4 is one character width
sta p0hpos
lda #32+4 ; adding one char?
sta p0vpos
routine
lda $14 ; slow things down
delay cmp $14 ; "
beq delay ; "
lda p0hpos ; store horizontal pos
sta 53248
sta 53249
lda #18 ;size of player
sta playcount
ldx frame ; begin height count
ldy p0vpos
drawloop
lda shape,x ; read shape data
sta $8400,y ; draw player
lda shape2,x ; read shape data
sta $8500,y ; draw player
inx
iny
dec playcount
lda playcount
bne drawloop ; ...and repeat
sty xpos
stx ypos
lda 644 ;trigger (0) pressed?
cmp #0
bne stickread
jsr set_adress
jsr check_walls
stickread
ldx 632
lda xstick,x
clc
adc p0hpos
sta p0hpos
lda ystick,x
clc
adc p0vpos
sta p0vpos
lda tabside,x
bne nochange
;frame rest = 0
sta frame
jmp routine
nochange
bpl rightmove
;leftmove
lda p0hpos
lsr a
lsr a
and #$03
tax
lda tabframeright,x
sta frame
jmp routine
rightmove
lda p0hpos
lsr a
lsr a
and #$03
tax
lda tabframeleft,x
sta frame
jmp routine
xstick .byte 0,0,0,0,0,1,1,1,0,$FF,$FF,$FF,0,0,0,0
ystick .byte 0,0,0,0,0,1,$FF,0,0,1,$FF,0,0,1,$FF,0
tabside .byte 0,0,0,0,0,1,1,1,0,$FF,$FF,$FF,0,0,0,0
tabframeright .byte 18,18,36,54 ;frames for move right
tabframeleft .byte 18,18,36,54 ;frames for move left - no frames yet
temp .byte 0
check_walls
;p1=robot -lefthigh corner
lda #33
ldy #$00
sta (p1),y
rts
set_adress
lda p0hpos
sec
sbc #48
lsr a
lsr a
sta temp
lda p0vpos
sec
sbc #32
lsr a
lsr a
lsr a
tax
lda sclo,x
sta p1
lda schi,x
sta p1+1
lda p1
clc
adc temp
sta p1
bcc skip
inc p1+1
skip
rts
*=$8000
shape
.byte 0,102,0,126,126,102,0,0,0,255,255,219,255,60,255,24,231,0; rest
.byte 0,126,120,126,126,126,0,0,0,255,255,251,255,60,109,255,182,0; frame 1, right
.byte 0,0,126,120,126,126,126,0,0,255,255,251,255,60,182,255,109,0; frame 2, right
.byte 0,0,0,126,120,126,126,126,0,255,255,253,255,60,219,126,219,0; frame 3, right
*=$8100
shape2
.byte 0,0,90,126,0,0,24,24,24,129,129,231,0,0,231,231,231,0; rest
.byte 0,0,6,6,0,0,24,24,24,48,96,24,0,0,255,129,255,0; frame 1, right
.byte 0,0,0,6,6,0,0,24,24,48,48,60,0,0,255,129,255,0 ;frame 2, right
.byte 0,0,0,0,6,6,0,0,24,48,24,14,0,0,255,129,255,0; frame 1, right
DLIST
.byte 112,112,112 ; blank lines
.byte 68,<scr,>scr ; 24 lines of ANTIC 4
.byte 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4
.byte 4,4,4,4,4,4,4
.byte 65,<DLIST,>DLIST ; Jump to top
*=$5000
;scr .ds 40*24 ; 960 bytes for screen
scr .sbyte "****************************************"
.sbyte "* *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* ===============*"
.sbyte "* ===============*"
.sbyte "* *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* ================ *"
.sbyte "* ================ *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* ========== *"
.sbyte "* ========== *"
.sbyte "* *"
.sbyte "* *"
.sbyte "* ========== *"
.sbyte "* ========== *"
.sbyte "* *"
.sbyte "****************************************"
sclo .ds 24
schi .ds 24