Sunday, February 19, 2012

Another Small Victory

Not leaving well enough alone, I had to come back in the shop this evening and convert another small test program that I got from an AtariAge.com helper.  This piece of code sets up the ANTIC with a display list, which really causes the ANTIC to interrupt the 6809E much more often.  The design holds up well though, because the Liber809 acts exactly the same as the 6502C version.  Sound is emitted and the screen stabilizes with some graphic skitzzle at the top.

Here's the 6502 code:


*=$8000
        .byte 0
;
        *= $FFFC
        .word reset
        .word 0
        *= $F000
reset
  sei
  jmp wait
  cld
  ldx #$FF
  txs  ; initialize 6502 mode and stack ptr
  inx
  txa
cleario
  sta $d000,x
  sta $d200,x
  sta $d300,x
  sta $d400,x
  dex
  bne cleario
  lda #3
  sta $d20f ; set Pokey to active
  ldx #$10
delay
  dex
  bne delay ; short delay for Pokey to start, probably not needed
  ldx #<dlist
  ldy #>dlist
  stx $d402
  sty $d403     ; setup DList pointer
  lda #$22
  sta $d400     ; DMA mode normal
  lda #$f0
  sta $d409     ; CHBase at $F000
  lda #$a0
  sta $d200
  lda #$a1
  sta $d202  ; set audf1 and audf2
  lda #0
  sta $d01a  ; Colour border/background
  lda #$82
  sta $d018     ; Colour background
  lda #$ca
  sta $d017     ; PF1 colour


  lda #$a8
  sta $d201
  sta $d203 ; set audc1 and audc2
wait
  jmp wait  ; loop forever
dlist
        .byte $70,$70,$70,$70
        .byte $42
        .word screen1
        .byte $42
        .word screen1
        .byte $41
        .word dlist
screen1
        .byte 0,1,2,3,4,5,6,7,8,9
        .byte 10,11,12,13,14,15,16,17,18,19
        .byte 0,1,2,3,4,5,6,7,8,9
        .byte 10,11,12,13,14,15,16,17,18,19



And the 6809 translation is next.  You'll notice that the ANTIC expects the addresses fed to it in little endian format.  This means I have to get the pointer to the dlist code, put it in the D register, then swap the two bytes and store that into $D402.  Also I've hard-coded the offsets in the dlist itself to be byte swapped.  Gotta add byte swapping functions to the mamou assembler.

 org $F000
reset
 orcc #$50              mask interrupts
 lds  #$00FF            stack pointer

* clear I/O
ClearIO
        clrb
loop
        ldx             #$D000
        clr             b,x
        ldx             #$D200
        clr             b,x
        ldx             #$D300
        clr             b,x
        ldx             #$D400
        clr             b,x
        decb
        bne             loop

* set POKEY active
 lda  #3
 sta  $D20F

* setup DList pointer
 leax dlist,pcr
 tfr x,d
 exg a,b
 std  $D402

 lda #$22
 sta $D400      DMA mode normal
 lda #$F0
 sta $D409      CHBase at $F000
 lda #$A0
 sta $D200
 lda #$A1
 sta $D202      set audf1 and audf2
 clra
 sta  $D10A     ; color border/background
 lda  #$82
 sta  $D018     ; color background
 lda  #$CA
 sta  $D017     ;PF1 color

 lda #$A8
 sta  $D201
 sta $D203      ; set audc1 and audc2

wait jmp wait

    fill $FF,$FF00-*

dlist
        fcb $70,$70,$70,$70
        fcb $42
*       fdb screen1
    fcb  $0D,$FF
        fcb $42
*       fdb screen1
    fcb  $0D,$FF
        fcb $41
*       fdb dlist
    fcb  $00,$FF
screen1
        fcb 0,1,2,3,4,5,6,7,8,9
        fcb 10,11,12,13,14,15,16,17,18,19
        fcb 0,1,2,3,4,5,6,7,8,9
        fcb 10,11,12,13,14,15,16,17,18,19

 fill  $FF,$FFF0-*
 fdb   reset
 fdb   reset
 fdb   reset
 fdb   reset
 fdb   reset
 fdb   reset
 fdb   reset
 fdb   reset




No comments:

Post a Comment