This is something I started shortly before I got crazy busy last year.
What could I be translating from 6502 to 6803 assembly, and why does it keep saying z80?
😎
<sigh> Only 6000+ lines left to translate.
;--------------------------------------------------------------
; Display sprites.
;
; Input:
; IX = sprite table
;--------------------------------------------------------------
dspr:
; lda #(NUMSPR/2) ; number of sprites to display.
; sta sprcnt
ldx z80_ix
ldaa #(NUMSPR/2) ; number of sprites to display.
staa sprcnt
dspr0:
; ldy #0
; lda (z80_ix),y ; get sprite type.
; cmp #255 ; is it enabled?
; bne dspr1 ; yes, it needs deleting.
ldx z80_ix
ldaa 0,x ; get sprite type
cmpa #255 ; is it enabled?
bne dspr1 ; yes, it needs deleting.
dspr5:
; ldy #5
; lda (z80_ix),y ; new type.
; cmp #255 ; is it enabled?
; bne dspr3 ; yes, it needs drawing.
ldx z80_ix
ldaa 5,x ; new type.
cmpa #255 ; is it enabled?
bne dspr3 ; yes, it needs drawing.
dspr2:
; ldy #5
; lda (z80_ix),y ; copy new type.
; ldy #0
; sta (z80_ix),y
; ldy #6
; lda (z80_ix),y ; copy new image number.
; ldy #1
; sta (z80_ix),y
ldx z80_ix
ldd 5,x ;copy new type 5 and image number 6
std 0,x ;> to 0 & 1
; ldy #7
; lda (z80_ix),y ; copy new frame.
; ldy #2
; sta (z80_ix),y
ldaa 7,x ; copy new frame
staa 2,x
; ldy #8
; lda (z80_ix),y ; copy new y.
; ldy #3
; sta (z80_ix),y
; ldy #9
; lda (z80_ix),y ; copy new x.
; ldy #4
; sta (z80_ix),y
ldd 8,x ; copy new y & x
std 3,x
; clc
; lda z80_x
; adc #(TABSIZ*2) ; distance to next odd/even entry.
; sta z80_x
; lda z80_i
; adc #0
; sta z80_i ; next sprite.
ldd z80_ix
addd #(TABSIZ*2) ; distance to next odd/even entry. next sprite.
std z80_ix
dec sprcnt
bne dspr0 ; repeat for remaining sprites.
rts
dspr1:
; ldy #5
; lda (z80_ix),y ; type of new sprite.
; cmp #255 ; is this enabled?
; bne dspr4 ; yes, display both.
ldx z80_ix
ldaa 5,x ; type of new sprite
cmpa #255 ; is this enabled?
bne dspr4 ; yes, display both.
dspr6:
jsr sspria ; show single sprite.
jmp dspr2
; Displaying two sprites. Don't bother redrawing if nothing has changed.
dspr4:
; ldy #4
; lda (z80_ix),y ; old x.
; ldy #9
; cmp (z80_ix),y ; compare with new value.
; bne dspr7 ; they differ, need to redraw.
; ldy #3
; lda (z80_ix),y ; old y.
; ldy #8
; cmp (z80_ix),y ; compare against new value.
; bne dspr7 ; they differ, need to redraw.
ldx z80_ix
ldd 3,x ; a = old y, b = old x
cmpa 9,x
bne dspr7 ; they differ, need to redraw.
cmpb 8,x ; compare against new value.
bne dspr7 ; then differ, need to redraw.
; ldy #2
; lda (z80_ix),y ; old frame.
; ldy #7
; cmp (z80_ix),y ; compare against new value.
; jmp dspr7 ; they differ, need to redraw.
ldaa 2,x ; old frame.
cmpa 7,x ; compare against new value.
; jmp dspr7 ; they differ, need to redraw
bne dspr7 ; they differ, need to redraw
; ldy #1
; lda (z80_ix),y ; old image.
; ldy #6
; cmp (z80_ix),y ; compare against new value.
; beq dspr2 ; everything is the same, don't redraw.
ldaa 1,x ; old image.
cmpa 6,x ; compare against new value.
beq dspr2 ; everything is the same, don't redraw.
dspr7:
jsr sspric ; delete old sprite, draw new one simultaneously.
; jmp dspr2
bra dspr2
dspr3:
jsr ssprib ; show single sprite.
; jmp dspr2
bra dspr2
sprcnt: .byte 0
What could I be translating from 6502 to 6803 assembly, and why does it keep saying z80?
😎
<sigh> Only 6000+ lines left to translate.
;--------------------------------------------------------------
; Display sprites.
;
; Input:
; IX = sprite table
;--------------------------------------------------------------
dspr:
; lda #(NUMSPR/2) ; number of sprites to display.
; sta sprcnt
ldx z80_ix
ldaa #(NUMSPR/2) ; number of sprites to display.
staa sprcnt
dspr0:
; ldy #0
; lda (z80_ix),y ; get sprite type.
; cmp #255 ; is it enabled?
; bne dspr1 ; yes, it needs deleting.
ldx z80_ix
ldaa 0,x ; get sprite type
cmpa #255 ; is it enabled?
bne dspr1 ; yes, it needs deleting.
dspr5:
; ldy #5
; lda (z80_ix),y ; new type.
; cmp #255 ; is it enabled?
; bne dspr3 ; yes, it needs drawing.
ldx z80_ix
ldaa 5,x ; new type.
cmpa #255 ; is it enabled?
bne dspr3 ; yes, it needs drawing.
dspr2:
; ldy #5
; lda (z80_ix),y ; copy new type.
; ldy #0
; sta (z80_ix),y
; ldy #6
; lda (z80_ix),y ; copy new image number.
; ldy #1
; sta (z80_ix),y
ldx z80_ix
ldd 5,x ;copy new type 5 and image number 6
std 0,x ;> to 0 & 1
; ldy #7
; lda (z80_ix),y ; copy new frame.
; ldy #2
; sta (z80_ix),y
ldaa 7,x ; copy new frame
staa 2,x
; ldy #8
; lda (z80_ix),y ; copy new y.
; ldy #3
; sta (z80_ix),y
; ldy #9
; lda (z80_ix),y ; copy new x.
; ldy #4
; sta (z80_ix),y
ldd 8,x ; copy new y & x
std 3,x
; clc
; lda z80_x
; adc #(TABSIZ*2) ; distance to next odd/even entry.
; sta z80_x
; lda z80_i
; adc #0
; sta z80_i ; next sprite.
ldd z80_ix
addd #(TABSIZ*2) ; distance to next odd/even entry. next sprite.
std z80_ix
dec sprcnt
bne dspr0 ; repeat for remaining sprites.
rts
dspr1:
; ldy #5
; lda (z80_ix),y ; type of new sprite.
; cmp #255 ; is this enabled?
; bne dspr4 ; yes, display both.
ldx z80_ix
ldaa 5,x ; type of new sprite
cmpa #255 ; is this enabled?
bne dspr4 ; yes, display both.
dspr6:
jsr sspria ; show single sprite.
jmp dspr2
; Displaying two sprites. Don't bother redrawing if nothing has changed.
dspr4:
; ldy #4
; lda (z80_ix),y ; old x.
; ldy #9
; cmp (z80_ix),y ; compare with new value.
; bne dspr7 ; they differ, need to redraw.
; ldy #3
; lda (z80_ix),y ; old y.
; ldy #8
; cmp (z80_ix),y ; compare against new value.
; bne dspr7 ; they differ, need to redraw.
ldx z80_ix
ldd 3,x ; a = old y, b = old x
cmpa 9,x
bne dspr7 ; they differ, need to redraw.
cmpb 8,x ; compare against new value.
bne dspr7 ; then differ, need to redraw.
; ldy #2
; lda (z80_ix),y ; old frame.
; ldy #7
; cmp (z80_ix),y ; compare against new value.
; jmp dspr7 ; they differ, need to redraw.
ldaa 2,x ; old frame.
cmpa 7,x ; compare against new value.
; jmp dspr7 ; they differ, need to redraw
bne dspr7 ; they differ, need to redraw
; ldy #1
; lda (z80_ix),y ; old image.
; ldy #6
; cmp (z80_ix),y ; compare against new value.
; beq dspr2 ; everything is the same, don't redraw.
ldaa 1,x ; old image.
cmpa 6,x ; compare against new value.
beq dspr2 ; everything is the same, don't redraw.
dspr7:
jsr sspric ; delete old sprite, draw new one simultaneously.
; jmp dspr2
bra dspr2
dspr3:
jsr ssprib ; show single sprite.
; jmp dspr2
bra dspr2
sprcnt: .byte 0
Yes I know there are some redundant LDX instructions.
ReplyDeleteonce I know more about the original code I can start removing them.
I'm not sure why I'm posting a "teaser", only a couple people read this unless I announce something.
ReplyDeleteIt's the runtime engine for AGD (Arcade Game Designer)
And FWIW, most of the code is about half the size of the 6502 version, but then the 6502 version could use some optimization.