Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user tubesockor ! (Registered 2024-05-12) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > codebase.c64.org
2007-05-08 09:29
Frantic

Registered: Mar 2003
Posts: 1628
codebase.c64.org

Hello!

Just wanted to tell you all that the C64 codebase wiki now got a proper URL and can be accessed through:

http://codebase.c64.org/

Enjoy! Greetings to Slaygon for supplying the URL. Now you don't have to remember that old weird URL. ;)

Keep on adding your stuff!

//FTC


 
... 24 posts hidden. Click here to view all posts....
 
2007-05-15 10:27
Graham
Account closed

Registered: Dec 2002
Posts: 990
Quote: Yes.. The only "problem" is that I dunno exactly how to handle such material in the best way possible. In one sense I think they should be read only, since it would be a distortion of the original material to have them wiki-editable...

Thoughts?


I think at first it should be open to grow to some "critical mass" until people find it valueable enough to go through the hazzle and open accounts.
2007-05-15 15:40
Raf

Registered: Nov 2003
Posts: 343
Quote: I think this wiki desperately needs a seperate forum and a bunch of "Discuss This Source in Forum"-like buttons attached to all the articles and sources. So that all discussions related to one particular source would remain in one forum thread and article related discussions would remain in one forum thread related to that particular article.

a discussion plugin for dkuwiki is avaialbe so commenting-discussing each page is possible .
Frantic , did you install that plugin?

www.vulture.c64.org
2007-05-15 17:39
Frantic

Registered: Mar 2003
Posts: 1628
A reply to some things touched on here..

As the poll on the mainpage shows, most people would like registration to become required for editing of contents. I respect the opinion of such a clear majority, so, that will happen. Only problem is that the server happened to be on a network that do not allow mail ports to be used freely, and the wiki uses mails in order to verify new accounts. A workaround is being worked on as we speak and if it fucks up for real, one can always change to some other server. Apart from this mail issue I am very satisfied with the current one though, so I won't just move to some other server without good reasons. Anyway, required registration will at least make sure you can see clearly who edited what, rather than the IP numbers you see right now. (Btw, if anyone really wants to, I can add them as users manually right now. Did that for Raf for example. Just send me a message with your desired username/password and your email, and I will take care of it.)

When it comes to the quality of the contents.. that is everyones responsibility. Note that you can write FIXME anywhere, and a yellow fixme button will appear. Check for example the one Raf added here:

http://wikholm.dyndns.org/~cswiki/doku.php?id=links:start#simul..

That is a good feature to use in case you cannot fix something yourself, but knows that it requires fixing in some way. (Although I think Raf used this feature slightly wrong in this case, since it does not relate to a problem with the contents of the wiki, but rather a tool completely external to the wiki. I'll probably modify this soon, but in the meantime I'll let it remain just so you can see just how such a FIXME flag looks.)

A forum.... Perhaps... I think the best way to handle that question will be another poll, which I'll put up when the mail issue is solved. "Do you want this site to have a forum? Yes/No/I CAN'T FUCKING DECIDE!!!" Good? (However, keep in mind that there is little danger involved here; Namely that crucial/good/important info related to a certain source/article then will be spread over the site in the article/source on the one hand and in the forum on the other hand, rather than all kept in a single place.) Anyway, I do see a point with being able to discuss something before changing/adding etc, so why not. But the poll will decide. As Raf says, there is a plugin for this, so there is no technical obstacle. It would obviosly also be a good feature in case someone has a question about some source/article...

Keep the opinions coming!

//FTC
2007-05-18 08:40
Fungus

Registered: Sep 2002
Posts: 625
Eh someone make a tut on how to edit this freakin wiki :D

I post some code here, someone move it over there... I can't be bothered.

-------------------------------------------------------------------------------- ----------------
You should be able to have 1 independant color per sprite, and also an independant image for each
sprite. You could also add fore/background priority buffers and add that register to your plot code.
 
 I chose to go for shortness in this routine rather than pure speed. It can be speeded up about
20% by unrolling all the plotting loops and using self modifed code instead of the second set 
of plotting buffers. d010 and d012 storing and comparing could also be precalculated.

 Now, the goods.

 We are using 32 sprites, so we are going to call this variable (maxspr) from here on. 
All of our defined tables will be of length(maxspr). The first table we need, is our linked
list. Our most important table, as we sort this linked list instead of all our tables.
Lets define it. 

maxspr = $1f
sort   = $02

       ldx #$00      ;init x with 00
loop   txa           ;transfer x to a to create index vals
       sta sort,x    ;store it in the sort table
       inx           
       cpx maxspr+1  ;have we reached 32 yet?
       bne loop

This routine puts numbers $00 to $1f (32) in the linked list table. Now we have our sort table defined.
The sort buffers can be in any memory area. I chose zeropage for speed. Now lets set up some sprites
and colors in our sprite data buffers. 

 each buffer takes (maxspr) number of bytes. 

ypos = $c000    ;sprite y position frame buffer
ybuf = $22      ;sprite y position raster buffer
xpos = $c020    ;sprite x position frame buffer
xbuf = $42      ;sprite x position raster buffer
xmsb = $c040    ;sprite x msb frame buffer
mbuf = $62      ;sprite x msb raster buffer
sprc = $c060    ;sprite color frame buffer
cbuf = $82      ;sprite color raster buffer
sprp = $c080    ;sprite pointer frame buffer
pbuf = $a2      ;sprite pointer raster buffer

      jsr movspr     ;preset sprite coordinates
      jsr anim       ;animate sprites
      jsr colors     ;adjust sprite colors.

 Now that we have set up some sprite to show, lets go ahead and precalculate the first frame
to prevent any update bugs, due to excessive sorting of the first frame. This is a special 
sorting algorythm, which I discovered on Cadaver's covert bit ops page. It comes from the
Imagine games done for Konami and several others. It's nice too see that good old 64
programmers came up with the idea of a prediction sort that long ago :) The speed of this
sorting technique is unmatched, it uses a prediction, which is really just the previous 
frame's sorted index. Y positions generally do no change by a radical amount from frame to
frame. This is ideal for Multiplexer sorting, as it takes less than 2000 cycles to sort 32 sprites.
Otherwise the routine is a simple swap sorter, which is not very complicated at all :)

 Here is the routine.

       ldx #$00         ;init x index to 00
loop1  ldy sort+1,x     ;load y index from linked list plus 1
loop2  lda ypos,y       ;load a with y position for that index
       ldy sort,x       ;load y index from linked list
       cmp ypos,y       ;compare yposition(index+1,x) to yposition(index,x)
       bcc swap         ;if yposition(index,x) is less than yposition(index+1,x) then swap the indexes
       inx              ;if more than, increment index
       cpx maxspr+1     ;checked all ypositions?
       bne loop1        ;no
       beq end          ;yes
swap   
       lda sort+1,x     ;swap yposition(index+1,x) with yposition(index,x)
       sta sort,x
       sty sort+1,x
       tay
       dex
       bpl loop2        ;if not first sprite loop to main
       inx              ;correct index
       beq loop1        ;restart sort from sprite(index+1,x)
end

Quite simple isnt it? 

 Ok, now lets setup our irq chian, so we can see this bumch of sprites weve just arranged.

       jsr setirq     ;setup irq.

    
In runtime code

main    lda timer     ;wait for signal, that the buffer swap is complete.
        sta mloop+1   
mloop   lda +      
        beq mloop

        jsr movspr    ;move sprites 
        jsr anim      ;animate sprites
        jsr color     ;animate colors
cont    jmp main      ;loop

setirq
      sei            ;set interrupt disable
      lda #$1b
      sta $d011      ;raster irq to 1st half of screen.
      lda #$fb
      sta $d012      ;irq to happen at line #$fb
      lda #<irq0
      sta $fffe      ;hardware irq vector low byte
      lda #>irq0
      sta $ffff      ;hardware irq vector high byte
      lda #$1f
      sta $dc0d      ;turn off all types of cia irq/nmi.
      sta $dd0d
      lda #$01
      sta $d01a      ;turn on raster irq.
      lda #$35
      sta $01        ;no basic or kernal
      lda $dc0d      ;acknowledge any irq that has occured during setup.
      lda $dd0d
      inc $d019
      cli            ;clear interrupt disable
      rts            ;return from subroutine


irq0
      pha            ;use stack instead of zp to prevent bugs.
      txa
      pha
      tya
      pha
      inc $d019      ;acknowledge irq
      ldx #$03       ;wait a few cycles
l1    dex
      bpl
      inx
      stx $d015      ;sprites off = more raster time in top/bottom border

slop  ldy sort+1,x   ;main index sort algo
slep  lda ypos,y
      ldy sort,x     ;this sorter uses the previous frame as a prediction buffer.
      cmp ypos,y     ;as y position does not change much from frame to frame.
      bcc swap       ;otherwise, it is a simple swap sort.
      inx            ;our linked list (sort) is sorted in decending order, according
      cpx #maxspr-1  ;to sprite y positions.
      bne slop
      beq end
swap 
      lda sort+1,x
      sta sort,x
      sty sort+1,x
      tay
      dex
      bpl slep
      inx
      beq slop
end

      ldy sort      ;re arrange frame buffers, into the raster buffers.
      lda ypos,y    ;this is unrolled for speed.
      sta ybuf      ;this allows us to use only 1 index pointer for our sprite plotter.
      lda xpos,y    ;it is double buffered, to allow runtime code to calculate the sprite
      sta xbuf      ;positions.
      lda xmsb,y
      sta mbuf
      lda sprc,y
      sta cbuf
      lda sprp,y
      sta pbuf

      ldy sort+1
      lda ypos,y
      sta ybuf+1
      lda xpos,y
      sta xbuf+1
      lda xmsb,y
      sta mbuf+1
      lda sprc,y
      sta cbuf+1
      lda sprp,y
      sta pbuf+1

and so on until max sprites.

      ldx #$00     ;find # of used sprites (you can remove sprites by
      stx sptr     ;placing #$ff into the ypos buffer for the corresponding
maxc  lda ybuf,x   ;sprite. It will not be displayed by the raster routine.
      cmp #$ff
      beq mxs
      inx
      cpx maxspr
      bne maxc
maxs  stx cnt      ;max sprites this frame count.
      cpx #$07     ;check if were doing more than 8
      bcc maxm     ;if not, we want the plotter to stop after 1 irq.
      ldx #$07     
maxm  stx mnt

      lda #$ff    ;reset sprites to off screen.
      sta $d001   ;prevents bugs.
      sta $d003
      sta $d005
      sta $d007
      sta $d009
      sta $d00b
      sta $d00d
      sta $d00f

      inc lsbtod   ;buffers are swapped, so we can do the next frame now.

      lda #<irq1   ;irq chain for raster code. prolly want a routine before
      sta $fffe    ;this one, to turn the sprites back on ;)
      lda #>irq1   ;i.e. lda #$ff sta $d015
      sta $ffff
      lda #$28
      sta $d012
      jmp eirq

Since the buffers have been reordered into proper decending order, we can use unrolled loops for the sprite
plotting. Each plot irq , is for each sprite in the order, 1,2,3,4,5,6,7,8 respectively.

We have a counter (mnt) for 0-7 sprites, as we want to go ahead an plot the first 8 sprites all at
once. We also have another counter (cnt) for the maximum number of sprites to display this frame.

If (mnt) has not been reached yet, each irq branches to the next, to plot the first 8 sprites.
After that, cnt is checked to see if were done plotting sprites. If not, each irq checks the postion of the
sprite from the previous frame, to see if its time to be done yet, if it is, it branches to the next irq. 
If it is not time yet, it calculates the next raster irq position and sets up the next irq.

By using the previous sprites position, you can properly chain the irqs down the screen, for much less 
"overlapping" bugs.

irq1
      pha           ;save registers
      txa
      pha
      tya
      pha
      inc $d019     ;acknowledge irq
      ldx sptr      ;get current sprite index
hlop1 lda ybuf,x    ;get sprite y position
      sta $d001     ;store sprite y postion.
      lda xbuf,x    ;get sprite x position.
      sta $d000     ;sta sprite x position.
      lda mbuf,x    ;get sprite x position msb
      bne no1       ;set msb register
      lda $d010
      ora #%00000001
      bne yes1
no1   lda $d010
      and #%11111110
yes1  sta $d010
      lda pbuf,x    ;get sprite image pointer
      sta $63f8     ;store it, double buffered screen.
      sta $67f8
      lda cbuf,x    ;get sprite color
      sta $d027     ;store sprite color
      inx           ;next sprite index
      cpx mnt       ;lets go to next plot, if < then 8 yet.
      bcc hlop2
      cpx cnt       ;no more sprites?
      bne ok1
      jmp done      ;no more sprites.

ok1   stx sptr      ;save sprite index
      lda $d003     ;get last position of next sprite
      clc
      adc #$15      ;add 21 lines
      cmp $d012     ;we there yet?
      bcc hlop2     ;yeah, so plot next sprite
      adc #$02      ;no, so calculate next irq position (+3)
      sta $d012     ;set it
      lda #<irq2    ;irq for next sprite.
      sta $fffe
      lda #>irq2
      sta $ffff
      jmp eirq

irq2
      pha           ;and so on
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop2 lda ybuf,x
      sta $d003
      lda xbuf,x
      sta $d002
      lda mbuf,x
      bne no2
      lda $d010
      ora #%00000010
      bne yes2
no2   lda $d010
      and #%11111101
yes2  sta $d010
      lda pbuf,x
      sta $63f9
      sta $67f9
      lda cbuf,x
      sta $d028
      inx
      cpx mnt
      bcc hlop3
      cpx cnt
      bne ok2
      jmp done

ok2   stx sptr
      lda $d005
      clc
      adc #$15
      cmp $d012
      bcc hlop3
      adc #$02
      sta $d012
      lda #<irq3
      sta $fffe
      lda #>irq3
      sta $ffff
      jmp eirq

irq3
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop3 lda ybuf,x
      sta $d005
      lda xbuf,x
      sta $d004
      lda mbuf,x
      bne no3
      lda $d010
      ora #%00000100
      bne yes3
no3   lda $d010
      and #%11111011
yes3  sta $d010
      lda pbuf,x
      sta $63fa
      sta $67fa
      lda cbuf,x
      sta $d029
      inx
      cpx mnt
      bcc hlop4
      cpx cnt
      bne ok3
      jmp done

ok3   stx sptr
      lda $d007
      clc
      adc #$15
      cmp $d012
      bcc hlop4
      adc #$02
      sta $d012
      lda #<irq4
      sta $fffe
      lda #>irq4
      sta $ffff
      jmp eirq

irq4  
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop4 lda ybuf,x
      sta $d007
      lda xbuf,x
      sta $d006
      lda mbuf,x
      bne no4
      lda $d010
      ora #%00001000
      bne yes4
no4   lda $d010
      and #%11110111
yes4  sta $d010
      lda pbuf,x
      sta $63fb
      sta $67fb
      lda cbuf,x
      sta $d02a
      inx
      cpx mnt
      bcc hlop5
      cpx cnt
      bne ok4
      jmp done

ok4   stx sptr
      lda $d009
      clc
      adc #$15
      cmp $d012
      bcc hlop5
      adc #$02
      sta $d012
      lda #<irq5
      sta $fffe
      lda #>irq5
      sta $ffff
      jmp eirq

irq5
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop5 lda ypos,x
      sta $d009
      lda xpos,x
      sta $d008
      lda mbuf,x
      bne no5
      lda $d010
      ora #%00010000
      bne yes5
no5   lda $d010
      and #%11101111
yes5  sta $d010
      lda pbuf,x
      sta $63fc
      sta $67fc
      lda cbuf,x
      sta $d02b
      inx
      cpx mnt
      bcc hlop6
      cpx cnt
      bne ok5
      jmp done

ok5   stx sptr
      lda $d00b
      clc
      adc #$15
      cmp $d012
      bcc hlop6
      adc #$02
      sta $d012
      lda #<irq6
      sta $fffe
      lda #>irq6
      sta $ffff
      jmp eirq

irq6
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop6 lda ybuf,x
      sta $d00b
      lda xbuf,x
      sta $d00a
      lda mbuf,x
      bne no6
      lda $d010
      ora #%00100000
      bne yes6
no6   lda $d010
      and #%11011111
yes6  sta $d010
      lda pbuf,x
      sta $63fd
      sta $67fd
      lda cbuf,x
      sta $d02c
      inx
      cpx mnt
      bcc hlop7
      cpx cnt
      bne ok6
      jmp done

ok6   stx sptr
      lda $d00d
      clc
      adc #$15
      cmp $d012
      bcc hlop7
      adc #$02
      sta $d012
      lda #<irq7
      sta $fffe
      lda #>irq7
      sta $ffff
      jmp eirq

irq7
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop7 lda ybuf,x
      sta $d00d
      lda xbuf,x
      sta $d00c
      lda mbuf,x
      bne no7
      lda $d010
      ora #%01000000
      bne yes7
no7   lda $d010
      and #%10111111
yes7  sta $d010
      lda pbuf,x
      sta $63fe
      sta $67fe
      lda cbuf,x
      sta $d02d
      inx
      cpx mnt
      bcc hlop8
      cpx cnt
      bne ok7
      jmp done

ok7   stx sptr
      lda $d00f
      clc
      adc #$15
      cmp $d012
      bcc hlop8
      adc #$02
      sta $d012
      lda #<irq8
      sta $fffe
      lda #>irq8
      sta $ffff
      jmp eirq

irq8 
      pha
      txa
      pha
      tya
      pha
      inc $d019
      ldx sptr
hlop8 lda ybuf,x
      sta $d00f
      lda xbuf,x
      sta $d00e
      lda mbuf,x
      bne no8
      lda $d010
      ora #%10000000
      bne yes8
no8   lda $d010
      and #%01111111
yes8  sta $d010
      lda pbuf,x
      sta $63ff
      sta $67ff
      lda cbuf,x
      sta $d02e
      inx
      cpx mnt
      bcc hlop9
      cpx cnt
      bne ok8
      jmp done

ok8   stx sptr
      lda $d001
      clc
      adc #$15
      cmp $d012
      bcc hlop9
      adc #$02
      sta $d012
      lda #<irq1
      sta $fffe
      lda #>irq1
      sta $ffff
      jmp eirq
hlop9 jmp hlop1

done  lda #<irq0
      sta $fffe
      lda #>irq0
      sta $ffff
      lda #$fb
      sta $d012
eirq        
      pla
      tay
      pla
      tax
      pla
      rti

END
2007-05-18 08:55
Oswald

Registered: Apr 2002
Posts: 5025
fungus, awesome. never ever saw a commented mplexer src so far :) how tight sprite formations can you do with it? what if 9 sprites on a row ? :)

edit:

lda $d003 ;get last position of next sprite
clc
adc #$15 ;add 21 lines
cmp $d012 ;we there yet?

I dont get this one, shouldnt we set the Y coord of the next sprite BEFORE it gets displayed?
2007-05-18 21:35
Fungus

Registered: Sep 2002
Posts: 625
Oswald: this is a bug I found in many multiplexer, you need to check that the last line of the previous sprite has been displayed, or the next one will NOT display properly ;)
2007-05-18 22:08
Oswald

Registered: Apr 2002
Posts: 5025
fungi, the last line of that sprite was already displayed in the prvs frame so no problems.

hmm or is this a way for 9th sprite eliminate?
2007-05-19 00:03
Fungus

Registered: Sep 2002
Posts: 625
well , since I can't fix the typo in my previous post ,here is another one.




;---------------------------------------
;Multiplexer 1999
;---------------------------------------

         *= $2400      ;origin

ysin     = $3800       ;y sinus

sort     = $05         ;sort buffer
xpos     = $0900       ;plot buffer
xbuf     = $05+($20)   ;raster buffer
ypos     = $0920
ybuf     = $05+($20*2)
sprc     = $0940
cbuf     = $05+($20*3)
sprp     = $0960
pbuf     = $05+($20*4)

sptr     = $02
mnt      = $03
cnt      = $04

xofs     = $04
yofs     = $04

maxspr   = $1f

;---------------------------------------
;game setup routines

         sei
         cld
         ldx #$02
        ;jsr $1000
         lda #<nmi
         ldx #>nmi
         sta $fffa
         sta $fffc
         stx $fffb
         stx $fffd
         lda #<ir0
         ldx #>ir0
         sta $fffe
         stx $ffff
         lda #$35
         sta $01
         lda #$00
         sta $d020
         sta $d021
         sta $d012
         lda #$1b
         sta $d011
         lda #$01
         sta $d01a
         lda #$1f
         sta $dc0d
         sta $dd0d
         lda $dc0d
         lda $dd0d

         lda #$08
         sta $d025    ;dark

         lda #$0c
         sta $d026    ;light

         ldx #maxspr
         lda #$02
ser      sta sprc,x
         dex
         bpl ser

         lda #$ff
         sta $d01c

         jsr mvspr

         ldx #$00
fuck     txa
         sta sort,x
         clc
         adc #$90
         sta sprp,x
         inx
         cpx #maxspr+1
         bne fuck

rset     ldx #$00
pols     ldy sort+1,x
plis     lda ypos,y
         ldy sort,x
         cmp ypos,y
         bcc paws
         inx
         cpx #maxspr
         bne pols
         bpl edn
paws     lda sort+1,x
         sta sort,x
         sty sort+1,x
         dex
         bpl pols
         inx
         beq plis
edn
         inc $d019
         lda $dc0d
         lda $dd0d

         cli

main     lda $b0
shit     cmp $b0
         beq shit
       ; inc $d020
         jsr mvspr
       ; jsr $1003
       ; dec $d020
         jmp main

;---------------------------------------
;experimental
;game irq routine

ir0
         pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx #$03
b1       dex
         bpl b1
         lda #$00
         sta $d015

         inc $d020

rest     ldx #$00      ;super sort
slop     ldy sort+1,x
slep     lda ypos,y
         ldy sort,x
         cmp ypos,y
         bcc swap
         inx
         cpx #maxspr
         bne slop
         beq end
swap
         lda sort+1,x
         sta sort,x
         sty sort+1,x
         tay
         dex
         bpl slep
         inx
         beq slep
end
         dec $d020

         ldy sort     ;re-order buffers
         lda ypos,y
         sta ybuf
         lda xpos,y
         sta xbuf
         lda sprc,y
         sta cbuf
         lda sprp,y
         sta pbuf

         ldy sort+1
         lda ypos,y
         sta ybuf+1
         lda xpos,y
         sta xbuf+1
         lda sprc,y
         sta cbuf+1
         lda sprp,y
         sta pbuf+1

         ldy sort+2
         lda ypos,y
         sta ybuf+2
         lda xpos,y
         sta xbuf+2
         lda sprc,y
         sta cbuf+2
         lda sprp,y
         sta pbuf+2

         ldy sort+3
         lda ypos,y
         sta ybuf+3
         lda xpos,y
         sta xbuf+3
         lda sprc,y
         sta cbuf+3
         lda sprp,y
         sta pbuf+3

         ldy sort+4
         lda ypos,y
         sta ybuf+4
         lda xpos,y
         sta xbuf+4
         lda sprc,y
         sta cbuf+4
         lda sprp,y
         sta pbuf+4

         ldy sort+5
         lda ypos,y
         sta ybuf+5
         lda xpos,y
         sta xbuf+5
         lda sprc,y
         sta cbuf+5
         lda sprp,y
         sta pbuf+5

         ldy sort+6
         lda ypos,y
         sta ybuf+6
         lda xpos,y
         sta xbuf+6
         lda sprc,y
         sta cbuf+6
         lda sprp,y
         sta pbuf+6

         ldy sort+7
         lda ypos,y
         sta ybuf+7
         lda xpos,y
         sta xbuf+7
         lda sprc,y
         sta cbuf+7
         lda sprp,y
         sta pbuf+7

         ldy sort+8
         lda ypos,y
         sta ybuf+8
         lda xpos,y
         sta xbuf+8
         lda sprc,y
         sta cbuf+8
         lda sprp,y
         sta pbuf+8

         ldy sort+9
         lda ypos,y
         sta ybuf+9
         lda xpos,y
         sta xbuf+9
         lda sprc,y
         sta cbuf+9
         lda sprp,y
         sta pbuf+9

         ldy sort+10
         lda ypos,y
         sta ybuf+10
         lda xpos,y
         sta xbuf+10
         lda sprc,y
         sta cbuf+10
         lda sprp,y
         sta pbuf+10

         ldy sort+11
         lda ypos,y
         sta ybuf+11
         lda xpos,y
         sta xbuf+11
         lda sprc,y
         sta cbuf+11
         lda sprp,y
         sta pbuf+11

         ldy sort+12
         lda ypos,y
         sta ybuf+12
         lda xpos,y
         sta xbuf+12
         lda sprc,y
         sta cbuf+12
         lda sprp,y
         sta pbuf+12

         ldy sort+13
         lda ypos,y
         sta ybuf+13
         lda xpos,y
         sta xbuf+13
         lda sprc,y
         sta cbuf+13
         lda sprp,y
         sta pbuf+13

         ldy sort+14
         lda ypos,y
         sta ybuf+14
         lda xpos,y
         sta xbuf+14
         lda sprc,y
         sta cbuf+14
         lda sprp,y
         sta pbuf+14

         ldy sort+15
         lda ypos,y
         sta ybuf+15
         lda xpos,y
         sta xbuf+15
         lda sprc,y
         sta cbuf+15
         lda sprp,y
         sta pbuf+15

         ldy sort+16
         lda ypos,y
         sta ybuf+16
         lda xpos,y
         sta xbuf+16
         lda sprc,y
         sta cbuf+16
         lda sprp,y
         sta pbuf+16

         ldy sort+17
         lda ypos,y
         sta ybuf+17
         lda xpos,y
         sta xbuf+17
         lda sprc,y
         sta cbuf+17
         lda sprp,y
         sta pbuf+17

         ldy sort+18
         lda ypos,y
         sta ybuf+18
         lda xpos,y
         sta xbuf+18
         lda sprc,y
         sta cbuf+18
         lda sprp,y
         sta pbuf+18

         ldy sort+19
         lda ypos,y
         sta ybuf+19
         lda xpos,y
         sta xbuf+19
         lda sprc,y
         sta cbuf+19
         lda sprp,y
         sta pbuf+19

         ldy sort+20
         lda ypos,y
         sta ybuf+20
         lda xpos,y
         sta xbuf+20
         lda sprc,y
         sta cbuf+20
         lda sprp,y
         sta pbuf+20

         ldy sort+21
         lda ypos,y
         sta ybuf+21
         lda xpos,y
         sta xbuf+21
         lda sprc,y
         sta cbuf+21
         lda sprp,y
         sta pbuf+21

         ldy sort+22
         lda ypos,y
         sta ybuf+22
         lda xpos,y
         sta xbuf+22
         lda sprc,y
         sta cbuf+22
         lda sprp,y
         sta pbuf+22

         ldy sort+23
         lda ypos,y
         sta ybuf+23
         lda xpos,y
         sta xbuf+23
         lda sprc,y
         sta cbuf+23
         lda sprp,y
         sta pbuf+23

         ldy sort+24
         lda ypos,y
         sta ybuf+24
         lda xpos,y
         sta xbuf+24
         lda sprc,y
         sta cbuf+24
         lda sprp,y
         sta pbuf+24

         ldy sort+25
         lda ypos,y
         sta ybuf+25
         lda xpos,y
         sta xbuf+25
         lda sprc,y
         sta cbuf+25
         lda sprp,y
         sta pbuf+25

         ldy sort+26
         lda ypos,y
         sta ybuf+26
         lda xpos,y
         sta xbuf+26
         lda sprc,y
         sta cbuf+26
         lda sprp,y
         sta pbuf+26

         ldy sort+27
         lda ypos,y
         sta ybuf+27
         lda xpos,y
         sta xbuf+27
         lda sprc,y
         sta cbuf+27
         lda sprp,y
         sta pbuf+27

         ldy sort+28
         lda ypos,y
         sta ybuf+28
         lda xpos,y
         sta xbuf+28
         lda sprc,y
         sta cbuf+28
         lda sprp,y
         sta pbuf+28

         ldy sort+29
         lda ypos,y
         sta ybuf+29
         lda xpos,y
         sta xbuf+29
         lda sprc,y
         sta cbuf+29
         lda sprp,y
         sta pbuf+29

         ldy sort+30
         lda ypos,y
         sta ybuf+30
         lda xpos,y
         sta xbuf+30
         lda sprc,y
         sta cbuf+30
         lda sprp,y
         sta pbuf+30

         ldy sort+31
         lda ypos,y
         sta ybuf+31
         lda xpos,y
         sta xbuf+31
         lda sprc,y
         sta cbuf+31
         lda sprp,y
         sta pbuf+31


         ldx #$00     ;find how many
         stx sptr     ;sprites
maxc     lda ybuf,x
         cmp #$ff
         beq maxs
         inx
         cpx #maxspr+1
         bne maxc
maxs     stx cnt
         cpx #$07
         bcc maxm
         ldx #$07
maxm     stx mnt

         lda #$ff
         sta $d001
         sta $d003
         sta $d005
         sta $d007
         sta $d009
         sta $d00b
         sta $d00d
         sta $d00f

         inc $b0

         lda #$02
         sta $dd00
         lda #$80
         sta $d018
         lda #$18
         sta $d016
         lda #$00
         sta $d021
         lda #$3b
         sta $d011
         lda #<ir1
         sta $fffe
         lda #>ir1
         sta $ffff
         lda #$28
         sta $d012
         jmp eirq
ir1
         pha
         txa
         pha
         tya
         pha
         inc $d019
         lda #$ff
         sta $d015
         ldx sptr
hlop1    lda ybuf,x
         sta $d001
         lda xbuf,x
         asl a           ;rm w/mbuf
         sta $d000
       ; lda mbuf,x
         bcc no1         ;beg w/mbuf
         lda $d010
         ora #%00000001
         bne yes1
no1      lda $d010
         and #%11111110
yes1     sta $d010
         lda pbuf,x
         sta $63f8
         lda cbuf,x
         sta $d027
         inx
         cpx mnt
         bcc hlop2
         cpx cnt
         bne ok1
         jmp done

ok1      stx sptr
         lda $d003
         clc
         adc #$15
         cmp $d012
         bcc hlop2
         adc #$02
         sta $d012
         lda #<ir2
         sta $fffe
         lda #>ir2
         sta $ffff
         jmp eirq

ir2      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop2    lda ybuf,x
         sta $d003
         lda xbuf,x
         asl a
         sta $d002
        ;lda mbuf,x
         bcc no2
         lda $d010
         ora #%00000010
         bne yes2
no2      lda $d010
         and #%11111101
yes2     sta $d010
         lda pbuf,x
         sta $63f9
         lda cbuf,x
         sta $d028
         inx
         cpx mnt
         bcc hlop3
         cpx cnt
         bne ok2
         jmp done

ok2      stx sptr
         lda $d005
         clc
         adc #$15
         cmp $d012
         bcc hlop3
         adc #$02
         sta $d012
         lda #<ir3
         sta $fffe
         lda #>ir3
         sta $ffff
         jmp eirq

ir3      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop3    lda ybuf,x
         sta $d005
         lda xbuf,x
         asl a
         sta $d004
        ;lda mbuf,x
         bcc no3
         lda $d010
         ora #%00000100
         bne yes3
no3      lda $d010
         and #%11111011
yes3     sta $d010
         lda pbuf,x
         sta $63fa
         lda cbuf,x
         sta $d029
         inx
         cpx mnt
         bcc hlop4
         cpx cnt
         bne ok3
         jmp done

ok3      stx sptr
         lda $d007
         clc
         adc #$15
         cmp $d012
         bcc hlop4
         adc #$02
         sta $d012
         lda #<ir4
         sta $fffe
         lda #>ir4
         sta $ffff
         jmp eirq

ir4      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop4    lda ybuf,x
         sta $d007
         lda xbuf,x
         asl a
         sta $d006
        ;lda mbuf,x
         bcc no4
         lda $d010
         ora #%00001000
         bne yes4
no4      lda $d010
         and #%11110111
yes4     sta $d010
         lda pbuf,x
         sta $63fb
         lda cbuf,x
         sta $d02a
         inx
         cpx mnt
         bcc hlop5
         cpx cnt
         bne ok4
         jmp done

ok4      stx sptr
         lda $d009
         clc
         adc #$15
         cmp $d012
         bcc hlop5
         adc #$02
         sta $d012
         lda #<ir5
         sta $fffe
         lda #>ir5
         sta $ffff
         jmp eirq

ir5      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop5    lda ybuf,x
         sta $d009
         lda xbuf,x
         asl a
         sta $d008
        ;lda mbuf,x
         bcc no5
         lda $d010
         ora #%00010000
         bne yes5
no5      lda $d010
         and #%11101111
yes5     sta $d010
         lda pbuf,x
         sta $63fc
         lda cbuf,x
         sta $d02b
         inx
         cpx mnt
         bcc hlop6
         cpx cnt
         bne ok5
         jmp done

ok5      stx sptr
         lda $d00b
         clc
         adc #$15
         cmp $d012
         bcc hlop6
         adc #$02
         sta $d012
         lda #<ir6
         sta $fffe
         lda #>ir6
         sta $ffff
         jmp eirq

ir6      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop6    lda ybuf,x
         sta $d00b
         lda xbuf,x
         asl a
         sta $d00a
       ; lda mbuf,x
         bcc no6
         lda $d010
         ora #%00100000
         bne yes6
no6      lda $d010
         and #%11011111
yes6     sta $d010
         lda pbuf,x
         sta $63fd
         lda cbuf,x
         sta $d02c
         inx
         cpx mnt
         bcc hlop7
         cpx cnt
         bne ok6
         jmp done

ok6      stx sptr
         lda $d00d
         clc
         adc #$15
         cmp $d012
         bcc hlop7
         adc #$02
         sta $d012
         lda #<ir7
         sta $fffe
         lda #>ir7
         sta $ffff
         jmp eirq

ir7      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop7    lda ybuf,x
         sta $d00d
         lda xbuf,x
         asl a
         sta $d00c
      ;  lda mbuf,x
         bcc no7
         lda $d010
         ora #%01000000
         bne yes7
no7      lda $d010
         and #%10111111
yes7     sta $d010
         lda pbuf,x
         sta $63fe
         lda cbuf,x
         sta $d02d
         inx
         cpx mnt
         bcc hlop8
         cpx cnt
         bne ok7
         jmp done

ok7      stx sptr
         lda $d00f
         clc
         adc #$15
         cmp $d012
         bcc hlop8
         adc #$02
         sta $d012
         lda #<ir8
         sta $fffe
         lda #>ir8
         sta $ffff
         jmp eirq

ir8      pha
         txa
         pha
         tya
         pha
         inc $d019
         ldx sptr
hlop8    lda ybuf,x
         sta $d00f
         lda xbuf,x
         asl a
         sta $d00e
        ;lda mbuf,x
         bcc no8
         lda $d010
         ora #%10000000
         bne yes8
no8      lda $d010
         and #%01111111
yes8     sta $d010
         lda pbuf,x
         sta $63ff
         lda cbuf,x
         sta $d02e
         inx
         cpx mnt
         bcc hlop9
         cpx cnt
         bne ok8
         jmp done

ok8      stx sptr
         lda $d001
         clc
         adc #$15
         cmp $d012
         bcc hlop9
         adc #$02
         sta $d012
         lda #<ir1
         sta $fffe
         lda #>ir1
         sta $ffff
         jmp eirq
hlop9    jmp hlop1

done     lda #<ir0
         sta $fffe
         lda #>ir0
         sta $ffff
         lda #$fb
         sta $d012
eirq
         pla
         tay
         pla
         tax
         pla
         rti

;---------------------------------------
;sprite movement

mvspr

;plot y

y1       lda ysin
         sta ypos
y2       lda ysin+yofs
         sta ypos+1
y3       lda ysin+(yofs*2)
         sta ypos+2
y4       lda ysin+(yofs*3)
         sta ypos+3
y5       lda ysin+(yofs*4)
         sta ypos+4
y6       lda ysin+(yofs*5)
         sta ypos+5
y7       lda ysin+(yofs*6)
         sta ypos+6
y8       lda ysin+(yofs*7)
         sta ypos+7
y9       lda ysin+(yofs*8)
         sta ypos+8
y10      lda ysin+(yofs*9)
         sta ypos+9
y11      lda ysin+(yofs*10)
         sta ypos+10
y12      lda ysin+(yofs*11)
         sta ypos+11
y13      lda ysin+(yofs*12)
         sta ypos+12
y14      lda ysin+(yofs*13)
         sta ypos+13
y15      lda ysin+(yofs*14)
         sta ypos+14
y16      lda ysin+(yofs*15)
         sta ypos+15
y17      lda ysin+(yofs*16)
         sta ypos+16
y18      lda ysin+(yofs*17)
         sta ypos+17
y19      lda ysin+(yofs*18)
         sta ypos+18
y20      lda ysin+(yofs*19)
         sta ypos+19
y21      lda ysin+(yofs*20)
         sta ypos+20
y22      lda ysin+(yofs*21)
         sta ypos+21
y23      lda ysin+(yofs*22)
         sta ypos+22
y24      lda ysin+(yofs*23)
         sta ypos+23
y25      lda ysin+(yofs*24)
         sta ypos+24
y26      lda ysin+(yofs*25)
         sta ypos+25
y27      lda ysin+(yofs*26)
         sta ypos+26
y28      lda ysin+(yofs*27)
         sta ypos+27
y29      lda ysin+(yofs*28)
         sta ypos+28
y30      lda ysin+(yofs*29)
         sta ypos+29
y31      lda ysin+(yofs*30)
         sta ypos+30
y32      lda ysin+(yofs*31)
         sta ypos+31
;plot x

x1       lda #$00
         sta xpos
x2       lda #$00+xofs
         sta xpos+1
x3       lda #$00+(xofs*2)
         sta xpos+2
x4       lda #$00+(xofs*3)
         sta xpos+3
x5       lda #$00+(xofs*4)
         sta xpos+4
x6       lda #$00+(xofs*5)
         sta xpos+5
x7       lda #$00+(xofs*6)
         sta xpos+6
x8       lda #$00+(xofs*7)
         sta xpos+7
x9       lda #$00+(xofs*8)
         sta xpos+8
x10      lda #$00+(xofs*9)
         sta xpos+9
x11      lda #$00+(xofs*10)
         sta xpos+10
x12      lda #$00+(xofs*11)
         sta xpos+11
x13      lda #$00+(xofs*12)
         sta xpos+12
x14      lda #$00+(xofs*13)
         sta xpos+13
x15      lda #$00+(xofs*14)
         sta xpos+14
x16      lda #$00+(xofs*15)
         sta xpos+15
x17      lda #$00+(xofs*16)
         sta xpos+16
x18      lda #$00+(xofs*17)
         sta xpos+17
x19      lda #$00+(xofs*18)
         sta xpos+18
x20      lda #$00+(xofs*19)
         sta xpos+19
x21      lda #$00+(xofs*20)
         sta xpos+20
x22      lda #$00+(xofs*21)
         sta xpos+21
x23      lda #$00+(xofs*22)
         sta xpos+22
x24      lda #$00+(xofs*23)
         sta xpos+23
x25      lda #$00+(xofs*24)
         sta xpos+24
x26      lda #$00+(xofs*25)
         sta xpos+25
x27      lda #$00+(xofs*26)
         sta xpos+26
x28      lda #$00+(xofs*27)
         sta xpos+27
x29      lda #$00+(xofs*28)
         sta xpos+28
x30      lda #$00+(xofs*29)
         sta xpos+29
x31      lda #$00+(xofs*30)
         sta xpos+30
x32      lda #$00+(xofs*31)
         sta xpos+31

        ;jmp cx
;move y
         inc y1+1
         inc y2+1
         inc y3+1
         inc y4+1
         inc y5+1
         inc y6+1
         inc y7+1
         inc y8+1
         inc y9+1
         inc y10+1
         inc y11+1
         inc y12+1
         inc y13+1
         inc y14+1
         inc y15+1
         inc y16+1
         inc y17+1
         inc y18+1
         inc y19+1
         inc y20+1
         inc y21+1
         inc y22+1
         inc y23+1
         inc y24+1
         inc y25+1
         inc y26+1
         inc y27+1
         inc y28+1
         inc y29+1
         inc y30+1
         inc y31+1
         inc y32+1
;move x
cx
         dec x1+1
         dec x2+1
         dec x3+1
         dec x4+1
         dec x5+1
         dec x6+1
         dec x7+1
         dec x8+1
         dec x9+1
         dec x10+1
         dec x11+1
         dec x12+1
         dec x13+1
         dec x14+1
         dec x15+1
         dec x16+1
         dec x17+1
         dec x18+1
         dec x19+1
         dec x20+1
         dec x21+1
         dec x22+1
         dec x23+1
         dec x24+1
         dec x25+1
         dec x26+1
         dec x27+1
         dec x28+1
         dec x29+1
         dec x30+1
         dec x31+1
         dec x32+1

;scroll wrap

         ldx #$b0
         lda x1+1
         cmp #$ff
         bne p1
         stx x1+1
p1       lda x2+1
         cmp #$ff
         bne p2
         stx x2+1
p2       lda x3+1
         cmp #$ff
         bne p3
         stx x3+1
p3       lda x4+1
         cmp #$ff
         bne p4
         stx x4+1
p4       lda x5+1
         cmp #$ff
         bne p5
         stx x5+1
p5       lda x6+1
         cmp #$ff
         bne p6
         stx x6+1
p6       lda x7+1
         cmp #$ff
         bne p7
         stx x7+1
p7       lda x8+1
         cmp #$ff
         bne p8
         stx x8+1
p8       lda x9+1
         cmp #$ff
         bne p9
         stx x9+1
p9       lda x10+1
         cmp #$ff
         bne p10
         stx x10+1
p10      lda x11+1
         cmp #$ff
         bne p11
         stx x11+1
p11      lda x12+1
         cmp #$ff
         bne p12
         stx x12+1
p12      lda x13+1
         cmp #$ff
         bne p13
         stx x13+1
p13      lda x14+1
         cmp #$ff
         bne p14
         stx x14+1
p14      lda x15+1
         cmp #$ff
         bne p15
         stx x15+1
p15      lda x16+1
         cmp #$ff
         bne p16
         stx x16+1
p16      lda x17+1
         cmp #$ff
         bne p17
         stx x17+1
p17      lda x18+1
         cmp #$ff
         bne p18
         stx x18+1
p18      lda x19+1
         cmp #$ff
         bne p19
         stx x19+1
p19      lda x20+1
         cmp #$ff
         bne p20
         stx x20+1
p20      lda x21+1
         cmp #$ff
         bne p21
         stx x21+1
p21      lda x22+1
         cmp #$ff
         bne p22
         stx x22+1
p22      lda x23+1
         cmp #$ff
         bne p23
         stx x23+1
p23      lda x24+1
         cmp #$ff
         bne p24
         stx x24+1
p24      lda x25+1
         cmp #$ff
         bne p25
         stx x25+1
p25      lda x26+1
         cmp #$ff
         bne p26
         stx x26+1
p26      lda x27+1
         cmp #$ff
         bne p27
         stx x27+1
p27      lda x28+1
         cmp #$ff
         bne p28
         stx x28+1
p28      lda x29+1
         cmp #$ff
         bne p29
         stx x29+1
p29      lda x30+1
         cmp #$ff
         bne p30
         stx x30+1
p30      lda x31+1
         cmp #$ff
         bne p31
         stx x31+1
p31      lda x32+1
         cmp #$ff
         bne p32
         stx x32+1
p32      rts

;---------------------------------------
;sprite animation


;---------------------------------------
;end

nmi
         lda #$37
         sta $01
         lda $dd0d
         jmp $9000

2007-05-19 00:06
Fungus

Registered: Sep 2002
Posts: 625
Here is a third unfinished one, with some minor bugs to be fixed.


;---------------------------------------
;New Multiplexer Engine
;24 sprite version
;
;Written by Fungus in 2005
;---------------------------------------

         *= $2000


xofs     = $06          ;x position
                        ;offset
yofs     = $06          ;x position
                        ;offset
ysin     = $3800

sort     = $02          ;index
ybuf     = $1a          ;y position
xbuf     = $32          ;x position
mbuf     = $0800        ;msb of x
pbuf     = $4a          ;image pointer
cbuf     = $52   ;-$69  ;color value

maxspr   = $18          ;24 sprites

setup
         sei
         cld
         lda #<irq0
         ldx #>irq0
         sta $fffe
         stx $ffff
         lda #<crap
         ldx #>crap
         sta $fffa
         sta $fffc
         stx $fffb
         stx $fffd

         lda #$01
         ldx #$fb
         sta $d01a
         stx $d012
         lda #$1b
         sta $d011
         lda #$7f
         sta $dc0d

         ldx #$17     ;init index tab
isort    txa
         sta sort,x
         dex
         bpl isort

         jsr move     ;init first frame
         jsr super

         lda #$35
         sta $01

         bit $dc0d
         inc $d019


         cli

;this routine in realtime

main

sw2      lda #$00
         bne nomove

         jsr move       ;move sprites
         jsr super
nomove
         jmp main


super    ldx #$00       ;super swap
a0       ldy sort+1,x   ;remember sort
a1       lda ybuf,y
         ldy sort,x
         cmp ybuf,y
         bcc swap
         inx
         cpx #maxspr-1
         bne a0
         beq send
swap     lda sort+1,x
         sta sort,x
         sty sort+1,x
         dex
         bpl a1
         inx
         beq a1
send     inc sw1+1      ;ok to swap!
         rts


;this routine inside irq

irq0
         pha
         txa
         pha
         tya
         pha

sw1      lda #$00       ;ok to swap?
         bne doit
         jmp skipit

doit     dec sw1+1
         inc sw2+1      ;tell main to
                        ;wait

         ldx idx        ;reset end of
                        ;irq chain
         lda entab,x
         sta ren+1
         lda entab+1,x
         sta ren+2
         lda #$00
ren      sta $1111

nrt      ldy #$00       ;mod irqs
         sty msb        ;sprite values
                        ;according to
                        ;index table

         ldx sort+0
         lda ybuf,x
         sta y1+1
         pha
         clc
         adc #$15
         sta r8+1
         lda xbuf,x
         sta x1+1
         lda mbuf,x
         bne no1
         lda msb
         ora ortab,y
         bne ye1
no1      lda msb
         and antab,y
ye1      sta m1+1
         lda pbuf,x
         sta p1+1
         lda cbuf,x
         sta c1+1
         iny
         ldx sort+1
         lda ybuf,x
         sta y2+1
         pha
         clc
         adc #$15
         sta r9+1
         lda xbuf,x
         sta x2+1
         lda mbuf,x
         bne no2
         lda msb
         ora ortab,y
         bne ye2
no2      lda msb
         and antab,y
ye2      sta m2+1
         lda pbuf,x
         sta p2+1
         lda cbuf,x
         sta c2+1
         iny
         ldx sort+2
         lda ybuf,x
         sta y3+1
         pha
         clc
         adc #$15
         sta r10+1
         lda xbuf,x
         sta x3+1
         lda mbuf,x
         bne no3
         lda msb
         ora ortab,y
         bne ye3
no3      lda msb
         and antab,y
ye3      sta m3+1
         lda pbuf,x
         sta p3+1
         lda cbuf,x
         sta c3+1
         iny
         ldx sort+3
         lda ybuf,x
         sta y4+1
         pha
         clc
         adc #$15
         sta r11+1
         lda xbuf,x
         sta x4+1
         lda mbuf,x
         bne no4
         lda msb
         ora ortab,y
         bne ye4
no4      lda msb
         and antab,y
ye4      sta m4+1
         lda pbuf,x
         sta p4+1
         lda cbuf,x
         sta c4+1
         iny
         ldx sort+4
         lda ybuf,x
         sta y5+1
         pha
         clc
         adc #$15
         sta r12+1
         lda xbuf,x
         sta x5+1
         lda mbuf,x
         bne no5
         lda msb
         ora ortab,y
         bne ye5
no5      lda msb
         and antab,y
ye5      sta m5+1
         lda pbuf,x
         sta p5+1
         lda cbuf,x
         sta c5+1
         iny
         ldx sort+5
         lda ybuf,x
         sta y6+1
         pha
         clc
         adc #$15
         sta r13+1
         lda xbuf,x
         sta x6+1
         lda mbuf,x
         bne no6
         lda msb
         ora ortab,y
         bne ye6
no6      lda msb
         and antab,y
ye6      sta m6+1
         lda pbuf,x
         sta p6+1
         lda cbuf,x
         sta c6+1
         iny
         ldx sort+6
         lda ybuf,x
         sta y7+1
         pha
         clc
         adc #$15
         sta r14+1
         lda xbuf,x
         sta x7+1
         lda mbuf,x
         bne no7
         lda msb
         ora ortab,y
         bne ye7
no7      lda msb
         and antab,y
ye7      sta m7+1
         lda pbuf,x
         sta p7+1
         lda cbuf,x
         sta c7+1
         iny
         ldx sort+7
         lda ybuf,x
         sta y8+1
         pha
         clc
         adc #$15
         sta r15+1
         lda xbuf,x
         sta x8+1
         lda mbuf,x
         bne no8
         lda msb
         ora ortab,y
         bne ye8
no8      lda msb
         and antab,y
ye8      sta m8+1
         lda pbuf,x
         sta p8+1
         lda cbuf,x
         sta c8+1
         ldy #$00
         ldx sort+8
         lda ybuf,x
         sta y9+1
         pha
         clc
         adc #$15
         sta r16+1
         lda xbuf,x
         sta x9+1
         lda mbuf,x
         bne no9
         lda msb
         ora ortab,y
         bne ye9
no9      lda msb
         and antab,y
ye9      sta m9+1
         lda pbuf,x
         sta p9+1
         lda cbuf,x
         sta c9+1
         iny
         ldx sort+10
         lda ybuf,x
         sta y10+1
         pha
         clc
         adc #$15
         sta r17+1
         lda xbuf,x
         sta x10+1
         lda mbuf,x
         bne no10
         lda msb
         ora ortab,y
         bne ye10
no10     lda msb
         and antab,y
ye10     sta m10+1
         lda pbuf,x
         sta p10+1
         lda cbuf,x
         sta c10+1
         iny
         ldx sort+10
         lda ybuf,x
         sta y11+1
         pha
         clc
         adc #$15
         sta r18+1
         lda xbuf,x
         sta x11+1
         lda mbuf,x
         bne no11
         lda msb
         ora ortab,y
         bne ye11
no11     lda msb
         and antab,y
ye11     sta m11+1
         lda pbuf,x
         sta p11+1
         lda cbuf,x
         sta c11+1
         iny
         ldx sort+11
         lda ybuf,x
         sta y12+1
         pha
         clc
         adc #$15
         sta r19+1
         lda xbuf,x
         sta x12+1
         lda mbuf,x
         bne no12
         lda msb
         ora ortab,y
         bne ye12
no12     lda msb
         and antab,y
ye12     sta m12+1
         lda pbuf,x
         sta p12+1
         lda cbuf,x
         sta c12+1
         iny
         ldx sort+12
         lda ybuf,x
         sta y13+1
         pha
         clc
         adc #$15
         sta r20+1
         lda xbuf,x
         sta x13+1
         lda mbuf,x
         bne no13
         lda msb
         ora ortab,y
         bne ye13
no13     lda msb
         and antab,y
ye13     sta m13+1
         lda pbuf,x
         sta p13+1
         lda cbuf,x
         sta c13+1
         iny
         ldx sort+13
         lda ybuf,x
         sta y14+1
         pha
         clc
         adc #$15
         sta r21+1
         lda xbuf,x
         sta x14+1
         lda mbuf,x
         bne no14
         lda msb
         ora ortab,y
         bne ye14
no14     lda msb
         and antab,y
ye14     sta m14+1
         lda pbuf,x
         sta p14+1
         lda cbuf,x
         sta c14+1
         iny
         ldx sort+14
         lda ybuf,x
         sta y15+1
         pha
         clc
         adc #$15
         sta r22+1
         lda xbuf,x
         sta x15+1
         lda mbuf,x
         bne no15
         lda msb
         ora ortab,y
         bne ye15
no15     lda msb
         and antab,y
ye15     sta m15+1
         lda pbuf,x
         sta p15+1
         lda cbuf,x
         sta c15+1
         iny
         ldx sort+15
         lda ybuf,x
         sta y16+1
         pha
         clc
         adc #$15
         sta r23+1
         lda xbuf,x
         sta x16+1
         lda mbuf,x
         bne no16
         lda msb
         ora ortab,y
         bne ye16
no16     lda msb
         and antab,y
ye16     sta m16+1
         lda pbuf,x
         sta p16+1
         lda cbuf,x
         sta c16+1
         ldy #$00
         ldx sort+16
         lda ybuf,x
         sta y17+1
         pha
         lda xbuf,x
         sta x17+1
         lda mbuf,x
         bne no17
         lda msb
         ora ortab,y
         bne ye17
no17     lda msb
         and antab,y
ye17     sta m17+1
         lda pbuf,x
         sta p17+1
         lda cbuf,x
         sta c17+1
         iny
         ldx sort+17
         lda ybuf,x
         sta y18+1
         pha
         lda xbuf,x
         sta x18+1
         lda mbuf,x
         bne no18
         lda msb
         ora ortab,y
         bne ye18
no18     lda msb
         and antab,y
ye18     sta m18+1
         lda pbuf,x
         sta p18+1
         lda cbuf,x
         sta c18+1
         iny
         ldx sort+18
         lda ybuf,x
         sta y19+1
         pha
         lda xbuf,x
         sta x19+1
         lda mbuf,x
         bne no19
         lda msb
         ora ortab,y
         bne ye19
no19     lda msb
         and antab,y
ye19     sta m19+1
         lda pbuf,x
         sta p19+1
         lda cbuf,x
         sta c19+1
         iny
         ldx sort+19
         lda ybuf,x
         sta y20+1
         pha
         lda xbuf,x
         sta x20+1
         lda mbuf,x
         bne no20
         lda msb
         ora ortab,y
         bne ye20
no20     lda msb
         and antab,y
ye20     sta m20+1
         lda pbuf,x
         sta p20+1
         lda cbuf,x
         sta c20+1
         iny
         ldx sort+20
         lda ybuf,x
         sta y21+1
         pha
         lda xbuf,x
         sta x21+1
         lda mbuf,x
         bne no21
         lda msb
         ora ortab,y
         bne ye21
no21     lda msb
         and antab,y
ye21     sta m21+1
         lda pbuf,x
         sta p21+1
         lda cbuf,x
         sta c21+1
         iny
         ldx sort+21
         lda ybuf,x
         sta y22+1
         pha
         lda xbuf,x
         sta x22+1
         lda mbuf,x
         bne no22
         lda msb
         ora ortab,y
         bne ye22
no22     lda msb
         and antab,y
ye22     sta m22+1
         lda pbuf,x
         sta p22+1
         lda cbuf,x
         sta c22+1
         iny
         ldx sort+22
         lda ybuf,x
         sta y23+1
         pha
         lda xbuf,x
         sta x23+1
         lda mbuf,x
         bne no23
         lda msb
         ora ortab,y
         bne ye23
no23     lda msb
         and antab,y
ye23     sta m23+1
         lda pbuf,x
         sta p23+1
         lda cbuf,x
         sta c23+1
         iny
         ldx sort+23
         lda ybuf,x
         sta y24+1
         pha
         lda xbuf,x
         sta x24+1
         lda mbuf,x
         bne no24
         lda msb
         ora ortab,y
         bne ye24
no24     lda msb
         and antab,y
ye24     sta m24+1
         lda pbuf,x
         sta p24+1
         lda cbuf,x
         sta c24+1

         ldx #$18     ;find count
cnt1     dex
         bmi none
         pla
         beq cnt1
         txa
         sta $fb      ;sprite count

rest     pla
         dex
         bpl rest
none
         lda $fb      ;set end of chain
         asl a        ;*2
         tax
         stx idx      ;save for next
         lda entab,x  ;frame
         sta sen+1
         lda entab+1,x
         sta sen+2
         lda #$01
sen      sta $1111    ;self modded

         dec sw2+1    ;ok to move
                      ;again

skipit
         lda #$2d
         sta $d012
         lda #<irq1
         sta $fffe
         lda #>irq1
         sta $ffff
         inc $d019
         pla
         tay
         pla
         tax
         pla
         rti
irq1

         pha
         inc $d019

         lda #$ff
         sta $d015

y1       lda #$00
         sta $d001
x1       lda #$00
         sta $d000
m1       lda #$00
         sta $d010
p1       lda #$00
         sta $63f8
         sta $67f8
c1       lda #$00
         sta $d027
e1       lda #$00
         beq s1
         jmp end
s1
y2       lda #$00
         sta $d003
x2       lda #$00
         sta $d002
m2       lda #$00
         sta $d010
p2       lda #$00
         sta $63f9
         sta $67f9
c2       lda #$00
         sta $d028
e2       lda #$00
         beq s2
         jmp end
s2
y3       lda #$00
         sta $d005
x3       lda #$00
         sta $d004
m3       lda #$00
         sta $d010
p3       lda #$00
         sta $63fa
         sta $67fa
c3       lda #$00
         sta $d029
e3       lda #$00
         beq s3
         jmp end
s3
y4       lda #$00
         sta $d007
x4       lda #$00
         sta $d006
m4       lda #$00
         sta $d010
p4       lda #$00
         sta $63fb
         sta $67fb
c4       lda #$00
         sta $d02a
e4       lda #$00
         beq s4
         jmp end
s4
y5       lda #$00
         sta $d009
x5       lda #$00
         sta $d008
m5       lda #$00
         sta $d010
p5       lda #$00
         sta $63fc
         sta $67fc
c5       lda #$00
         sta $d02b
e5       lda #$00
         beq s5
         jmp end
s5
y6       lda #$00
         sta $d00b
x6       lda #$00
         sta $d00a
m6       lda #$00
         sta $d010
p6       lda #$00
         sta $63fd
         sta $67fd
c6       lda #$00
         sta $d02c
e6       lda #$00
         beq s6
         jmp end
s6
y7       lda #$00
         sta $d00d
x7       lda #$00
         sta $d00c
m7       lda #$00
         sta $d010
p7       lda #$00
         sta $63fe
         sta $67fe
c7       lda #$00
         sta $d02d
e7       lda #$00
         beq s7
         jmp end
s7
y8       lda #$00
         sta $d00f
x8       lda #$00
         sta $d00e
m8       lda #$00
         sta $d010
p8       lda #$00
         sta $63ff
         sta $67ff
c8       lda #$00
         sta $d02e
e8       lda #$00
         beq s8
         jmp end
s8
         lda #$00
         bne y9
r8       lda #$00
         sta $d012
         lda #<irq2
         sta $fffe
         lda #>irq2
         sta $ffff
         pla
         rti
irq2
         pha
         inc $d019

y9       lda #$00
         sta $d001
x9       lda #$00
         sta $d000
m9       lda #$00
         sta $d010
p9       lda #$00
         sta $63f8
         sta $67f8
c9       lda #$00
         sta $d027
e9       lda #$00
         beq s9
         jmp end
s9

         lda #$00
         bne y10
r9       lda #$00
         sta $d012
         lda #<irq3
         sta $fffe
         lda #>irq3
         sta $ffff
         pla
         rti
irq3
         pha
         inc $d019

y10      lda #$00
         sta $d003
x10      lda #$00
         sta $d002
m10      lda #$00
         sta $d010
p10      lda #$00
         sta $63f9
         sta $67f9
c10      lda #$00
         sta $d028
e10      lda #$00
         beq s10
         jmp end
s10
         lda #$00
         bne y11
r10      lda #$00
         sta $d012
         lda #<irq4
         sta $fffe
         lda #>irq4
         sta $ffff
         pla
         rti
irq4
         pha
         inc $d019

y11      lda #$00
         sta $d005
x11      lda #$00
         sta $d004
m11      lda #$00
         sta $d010
p11      lda #$00
         sta $63fa
         sta $67fa
c11      lda #$00
         sta $d029
e11      lda #$00
         beq s11
         jmp end
s11
         lda #$00
         bne y12
r11      lda #$00
         sta $d012
         lda #<irq5
         sta $fffe
         lda #>irq5
         sta $ffff
         pla
         rti
irq5
         pha
         inc $d019

y12      lda #$00
         sta $d007
x12      lda #$00
         sta $d006
m12      lda #$00
         sta $d010
p12      lda #$00
         sta $63fb
         sta $67fb
c12      lda #$00
         sta $d02a
e12      lda #$00
         beq s12
         jmp end
s12
         lda #$00
         bne y14
r12      lda #$00
         sta $d012
         lda #<irq6
         sta $fffe
         lda #>irq6
         sta $ffff
         pla
         rti
irq6
         pha
         inc $d019

y13      lda #$00
         sta $d009
x13      lda #$00
         sta $d008
m13      lda #$00
         sta $d010
p13      lda #$00
         sta $63fc
         sta $67fc
c13      lda #$00
         sta $d02b
e13      lda #$00
         beq s13
         jmp end
s13
         lda #$00
         bne y15
r13      lda #$00
         sta $d012
         lda #<irq7
         sta $fffe
         lda #>irq7
         sta $ffff
         pla
         rti
irq7
         pha
         inc $d019

y14      lda #$00
         sta $d00b
x14      lda #$00
         sta $d00a
m14      lda #$00
         sta $d010
p14      lda #$00
         sta $63fd
         sta $67fd
c14      lda #$00
         sta $d02c
e14      lda #$00
         beq s14
         jmp end
s14
         lda #$00
         bne y16
r14      lda #$00
         sta $d012
         lda #<irq8
         sta $fffe
         lda #>irq8
         sta $ffff
         pla
         rti
irq8
         pha
         inc $d019

y15      lda #$00
         sta $d00d
x15      lda #$00
         sta $d00c
m15      lda #$00
         sta $d010
p15      lda #$00
         sta $63fe
         sta $67fe
c15      lda #$00
         sta $d02d
e15      lda #$00
         beq s15
         jmp end
s15
         lda #$00
         bne y17
r15      lda #$00
         sta $d012
         lda #<irq9
         sta $fffe
         lda #>irq9
         sta $ffff
         pla
         rti
irq9
         pha
         inc $d019

y16      lda #$00
         sta $d00f
x16      lda #$00
         sta $d00e
m16      lda #$00
         sta $d010
p16      lda #$00
         sta $63ff
         sta $67ff
c16      lda #$00
         sta $d02e
e16      lda #$00
         beq s16
         jmp end
s16
         lda #$00
         bne y17
r16      lda #$00
         sta $d012
         lda #<irqa
         sta $fffe
         lda #>irqa
         sta $ffff
         pla
         rti

irqa
         pha
         inc $d019

y17      lda #$00
         sta $d001
x17      lda #$00
         sta $d000
m17      lda #$00
         sta $d010
p17      lda #$00
         sta $63f8
         sta $67f8
c17      lda #$00
         sta $d027
e17      lda #$00
         beq s17
         jmp end
s17

         lda #$00
         bne y18
r17      lda #$00
         sta $d012
         lda #<irqb
         sta $fffe
         lda #>irqb
         sta $ffff
         pla
         rti
irqb
         pha
         inc $d019

y18      lda #$00
         sta $d003
x18      lda #$00
         sta $d002
m18      lda #$00
         sta $d010
p18      lda #$00
         sta $63f9
         sta $67f9
c18      lda #$00
         sta $d028
e18      lda #$00
         beq s18
         jmp end
s18
         lda #$00
         bne y19
r18      lda #$00
         sta $d012
         lda #<irqc
         sta $fffe
         lda #>irqc
         sta $ffff
         pla
         rti
irqc
         pha
         inc $d019

y19      lda #$00
         sta $d005
x19      lda #$00
         sta $d004
m19      lda #$00
         sta $d010
p19      lda #$00
         sta $63fa
         sta $67fa
c19      lda #$00
         sta $d029
e19      lda #$00
         beq s19
         jmp end
s19
         lda #$00
         bne y20
r19      lda #$00
         sta $d012
         lda #<irqd
         sta $fffe
         lda #>irqd
         sta $ffff
         pla
         rti
irqd
         pha
         inc $d019

y20      lda #$00
         sta $d007
x20      lda #$00
         sta $d006
m20      lda #$00
         sta $d010
p20      lda #$00
         sta $63fb
         sta $67fb
c20      lda #$00
         sta $d02a
e20      lda #$00
         beq s20
         jmp end
s20
         lda #$00
         bne y21
r20      lda #$00
         sta $d012
         lda #<irqe
         sta $fffe
         lda #>irqe
         sta $ffff
         pla
         rti
irqe
         pha
         inc $d019

y21      lda #$00
         sta $d009
x21      lda #$00
         sta $d008
m21      lda #$00
         sta $d010
p21      lda #$00
         sta $63fc
         sta $67fc
c21      lda #$00
         sta $d02b
e21      lda #$00
         beq s21
         jmp end
s21
         lda #$00
         bne y22
r21      lda #$00
         sta $d012
         lda #<irqf
         sta $fffe
         lda #>irqf
         sta $ffff
         pla
         rti
irqf
         pha
         inc $d019

y22      lda #$00
         sta $d00b
x22      lda #$00
         sta $d00a
m22      lda #$00
         sta $d010
p22      lda #$00
         sta $63fd
         sta $67fd
c22      lda #$00
         sta $d02c
e22      lda #$00
         beq s22
         jmp end
s22
         lda #$00
         bne y23
r22      lda #$00
         sta $d012
         lda #<irqg
         sta $fffe
         lda #>irqg
         sta $ffff
         pla
         rti
irqg
         pha
         inc $d019

y23      lda #$00
         sta $d00d
x23      lda #$00
         sta $d00c
m23      lda #$00
         sta $d010
p23      lda #$00
         sta $63fe
         sta $67fe
c23      lda #$00
         sta $d02d
e23      lda #$00
         beq s23
         jmp end
s23
         lda #$00
         bne y24
r23      lda #$00
         sta $d012
         lda #<irqh
         sta $fffe
         lda #>irqh
         sta $ffff
         pla
         rti
irqh
         pha
         inc $d019

y24      lda #$00
         sta $d00f
x24      lda #$00
         sta $d00e
m24      lda #$00
         sta $d010
p24      lda #$00
         sta $63ff
         sta $67ff
c24      lda #$00
         sta $d02e
                      ;end here
e24      lda #$00
end      lda #$00
         sta $d012
         lda #<irq0
         sta $fffe
         lda #>irq0
         sta $ffff
         pla
crap     rti

idx      .byte $ff
msb      .byte $ff

ortab
         .byte %10000000
         .byte %01000000
         .byte %00100000
         .byte %00010000
         .byte %00001000
         .byte %00000100
         .byte %00000010
         .byte %00000001
antab
         .byte %01111111
         .byte %10111111
         .byte %11011111
         .byte %11101111
         .byte %11110111
         .byte %11111011
         .byte %11111101
         .byte %11111110

en01     = e1+1
en02     = e2+1
en03     = e3+1
en04     = e4+1
en05     = e5+1
en06     = e6+1
en07     = e7+1
en08     = e8+1
en09     = e9+1
en10     = e10+1
en11     = e11+1
en12     = e12+1
en13     = e13+1
en14     = e14+1
en15     = e15+1
en16     = e16+1
en17     = e17+1
en18     = e18+1
en19     = e19+1
en20     = e20+1
en21     = e21+1
en22     = e22+1
en23     = e23+1
en24     = e24+1

entab
         .byte <en01,>en01
         .byte <en02,>en02
         .byte <en03,>en03
         .byte <en04,>en04
         .byte <en05,>en05
         .byte <en06,>en06
         .byte <en07,>en07
         .byte <en08,>en08
         .byte <en09,>en09
         .byte <en10,>en10
         .byte <en11,>en11
         .byte <en12,>en12
         .byte <en13,>en13
         .byte <en14,>en14
         .byte <en15,>en15
         .byte <en16,>en16
         .byte <en17,>en17
         .byte <en18,>en18
         .byte <en19,>en19
         .byte <en20,>en20
         .byte <en21,>en21
         .byte <en22,>en22
         .byte <en23,>en23
         .byte <en24,>en24


;---------------------------------------
;sprite movement

move

;plot y

j1       lda ysin
         sta ybuf
j2       lda ysin+yofs
         sta ybuf+1
j3       lda ysin+(yofs*2)
         sta ybuf+2
j4       lda ysin+(yofs*3)
         sta ybuf+3
j5       lda ysin+(yofs*4)
         sta ybuf+4
j6       lda ysin+(yofs*5)
         sta ybuf+5
j7       lda ysin+(yofs*6)
         sta ybuf+6
j8       lda ysin+(yofs*7)
         sta ybuf+7
j9       lda ysin+(yofs*8)
         sta ybuf+8
j10      lda ysin+(yofs*9)
         sta ybuf+9
j11      lda ysin+(yofs*10)
         sta ybuf+10
j12      lda ysin+(yofs*11)
         sta ybuf+11
j13      lda ysin+(yofs*12)
         sta ybuf+12
j14      lda ysin+(yofs*13)
         sta ybuf+13
j15      lda ysin+(yofs*14)
         sta ybuf+14
j16      lda ysin+(yofs*15)
         sta ybuf+15
j17      lda ysin+(yofs*16)
         sta ybuf+16
j18      lda ysin+(yofs*17)
         sta ybuf+17
j19      lda ysin+(yofs*18)
         sta ybuf+18
j20      lda ysin+(yofs*19)
         sta ybuf+19
j21      lda ysin+(yofs*20)
         sta ybuf+20
j22      lda ysin+(yofs*21)
         sta ybuf+21
j23      lda ysin+(yofs*22)
         sta ybuf+22
j24      lda ysin+(yofs*23)
         sta ybuf+23
;plot x

k1       lda #$00
         sta xbuf
k2       lda #$00+xofs
         sta xbuf+1
k3       lda #$00+(xofs*2)
         sta xbuf+2
k4       lda #$00+(xofs*3)
         sta xbuf+3
k5       lda #$00+(xofs*4)
         sta xbuf+4
k6       lda #$00+(xofs*5)
         sta xbuf+5
k7       lda #$00+(xofs*6)
         sta xbuf+6
k8       lda #$00+(xofs*7)
         sta xbuf+7
k9       lda #$00+(xofs*8)
         sta xbuf+8
k10      lda #$00+(xofs*9)
         sta xbuf+9
k11      lda #$00+(xofs*10)
         sta xbuf+10
k12      lda #$00+(xofs*11)
         sta xbuf+11
k13      lda #$00+(xofs*12)
         sta xbuf+12
k14      lda #$00+(xofs*13)
         sta xbuf+13
k15      lda #$00+(xofs*14)
         sta xbuf+14
k16      lda #$00+(xofs*15)
         sta xbuf+15
k17      lda #$00+(xofs*16)
         sta xbuf+16
k18      lda #$00+(xofs*17)
         sta xbuf+17
k19      lda #$00+(xofs*18)
         sta xbuf+18
k20      lda #$00+(xofs*19)
         sta xbuf+19
k21      lda #$00+(xofs*20)
         sta xbuf+20
k22      lda #$00+(xofs*21)
         sta xbuf+21
k23      lda #$00+(xofs*22)
         sta xbuf+22
k24      lda #$00+(xofs*23)
         sta xbuf+23

        ;jmp cx
;move y
         inc j1+1
         inc j2+1
         inc j3+1
         inc j4+1
         inc j5+1
         inc j6+1
         inc j7+1
         inc j8+1
         inc j9+1
         inc j10+1
         inc j11+1
         inc j12+1
         inc j13+1
         inc j14+1
         inc j15+1
         inc j16+1
         inc j17+1
         inc j18+1
         inc j19+1
         inc j20+1
         inc j21+1
         inc j22+1
         inc j23+1
         inc j24+1
;move x
cx
         dec k1+1
         dec k2+1
         dec k3+1
         dec k4+1
         dec k5+1
         dec k6+1
         dec k7+1
         dec k8+1
         dec k9+1
         dec k10+1
         dec k11+1
         dec k12+1
         dec k13+1
         dec k14+1
         dec k15+1
         dec k16+1
         dec k17+1
         dec k18+1
         dec k19+1
         dec k20+1
         dec k21+1
         dec k22+1
         dec k23+1
         dec k24+1

;scroll wrap

         ldx #$b0
         lda k1+1
         cmp #$ff
         bne n1
         stx k1+1
n1       lda k2+1
         cmp #$ff
         bne n2
         stx k2+1
n2       lda k3+1
         cmp #$ff
         bne n3
         stx k3+1
n3       lda k4+1
         cmp #$ff
         bne n4
         stx k4+1
n4       lda k5+1
         cmp #$ff
         bne n5
         stx k5+1
n5       lda k6+1
         cmp #$ff
         bne n6
         stx k6+1
n6       lda k7+1
         cmp #$ff
         bne n7
         stx k7+1
n7       lda k8+1
         cmp #$ff
         bne n8
         stx k8+1
n8       lda k9+1
         cmp #$ff
         bne n9
         stx k9+1
n9       lda k10+1
         cmp #$ff
         bne n10
         stx k10+1
n10      lda k11+1
         cmp #$ff
         bne n11
         stx k11+1
n11      lda k12+1
         cmp #$ff
         bne n12
         stx k12+1
n12      lda k13+1
         cmp #$ff
         bne n13
         stx k13+1
n13      lda k14+1
         cmp #$ff
         bne n14
         stx k14+1
n14      lda k15+1
         cmp #$ff
         bne n15
         stx k15+1
n15      lda k16+1
         cmp #$ff
         bne n16
         stx k16+1
n16      lda k17+1
         cmp #$ff
         bne n17
         stx k17+1
n17      lda k18+1
         cmp #$ff
         bne n18
         stx k18+1
n18      lda k19+1
         cmp #$ff
         bne n19
         stx k19+1
n19      lda k20+1
         cmp #$ff
         bne n20
         stx k20+1
n20      lda k21+1
         cmp #$ff
         bne n21
         stx k21+1
n21      lda k22+1
         cmp #$ff
         bne n22
         stx k22+1
n22      lda k23+1
         cmp #$ff
         bne n23
         stx k23+1
n23      lda k24+1
         cmp #$ff
         bne n24
         stx k24+1
n24      lda k25+1
         cmp #$ff
         bne n25
         stx k25+1
n25
         rts




2007-05-19 00:08
Fungus

Registered: Sep 2002
Posts: 625
and now a (simple) VSP routine to bounce a koala pic.


;---------------------------------------
;Variable Screen Positioning (VSP)
;
;Coded by Fungus
;---------------------------------------

         *= $1000

         sei
         lda #$35
         sta $01
r1       bit $d011    ;wait
         bpl r1
r2       bit $d011
         bmi r2
         lda #$00
         sta $d020    ;border
         lda #$00
         sta $d021    ;background
         lda #$7f     ;remove timer
         sta $dc0d    ;irqs
         sta $dd0d
         lda $dc0d
         lda $dd0d
         lda #$58
         sta $d011
         lda #$03
         ldx #$18
         ldy #$28
         sta $dd00
         stx $d016
         sty $d018
         ldx #$00     ;clear colors
c0       lda #$00
         sta $d800,x
         sta $d900,x
         sta $da00,x
         sta $db00,x
         sta $0800,x
         sta $0900,x
         sta $0a00,x
         sta $0b00,x
         lda #$20     ;blank normal
         sta $0400,x  ;screen
         sta $0500,x
         sta $0600,x
         sta $0700,x
         inx
         bne c0
         bit $d011    ;wait
         bpl *-3
         bit $d011
         bmi *-3
         lda #$39
         sta $d011
         lda #<rt     ;setup irq
         ldx #>rt
         sta $fffa
         stx $fffb
         lda #$2d
         sta $d012
         lda #<irq1
         ldx #>irq1
         ldy #$01
         sta $fffe
         stx $ffff
         sty $d01a
         lda $d019
         sta $d019
         cli

m1       jmp m1
rt
         lda #$37
         sta $01
         jmp $9000


         *= $1100
irq1                  ;double irq
         inc $d019    ;stable raster
         sta s1+1
         stx s2+1
         sty s3+1
         lda #$2e
         ldx #<irq2
         ldy #>irq2
         sta $d012
         stx $fffe
         sty $ffff
         tsx
         cmp $00
         cli
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop
         nop

irq2     txs
         ldx #$09
l1       dex
         bne l1
         nop
         lda #$2e     ;65 cycles w/irq
         cmp $d012    ;make it stable
         beq k1
k1

         ldx #$0b     ;waste a line
         dex
         bne *-1
         nop          ;65 cyles
         nop
         nop
         lda #$00     ;delayer
k4       beq k5       ;for 16 pixel
                      ;hard scroll
k5       cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         cmp #$c9
         bit $ea

         lda #$38     ;start dma here!
         sta $d011
         lda #$39     ;turn back off now
         sta $d011    ;to prevent bugs

         inc $d019
         lda #$fb     ;next irq
         ldx #<irq3
         ldy #>irq3
exit     sta $d012
         stx $fffe
         sty $ffff
s1       lda #$00
s2       ldx #$00
s3       ldy #$00
         rti
irq3
n0       lda $1600
         sta $d016
n1       lda $1700
         sta k4+1
         sec
p8       sbc #$01
p9       cmp #$80
         bcc p2
         jmp p1
p2       jmp p3

p3       tax
         lda $1800,x
         sta $0800,x
         lda $1c00,x
         sta $d800,x
         lda $1800+$28,x
         sta $0800+$28,x
         lda $1c00+$28,x
         sta $d800+$28,x
         lda $1800+$50,x
         sta $0800+$50,x
         lda $1c00+$50,x
         sta $d800+$50,x
         lda $1800+$78,x
         sta $0800+$78,x
         lda $1c00+$78,x
         sta $d800+$78,x
         lda $1800+$a0,x
         sta $0800+$a0,x
         lda $1c00+$a0,x
         sta $d800+$a0,x
         lda $1800+$c8,x
         sta $0800+$c8,x
         lda $1c00+$c8,x
         sta $d800+$c8,x
         lda $1800+$f0,x
         sta $0800+$f0,x
         lda $1c00+$f0,x
         sta $d800+$f0,x
         lda $1800+$0118,x
         sta $0800+$0118,x
         lda $1c00+$0118,x
         sta $d800+$0118,x
         lda $1800+$0140,x
         sta $0800+$0140,x
         lda $1c00+$0140,x
         sta $d800+$0140,x
         lda $1800+$0168,x
         sta $0800+$0168,x
         lda $1c00+$0168,x
         sta $d800+$0168,x
         lda $1800+$0190,x
         sta $0800+$0190,x
         lda $1c00+$0190,x
         sta $d800+$0190,x
         lda $1800+$01b8,x
         sta $0800+$01b8,x
         lda $1c00+$01b8,x
         sta $d800+$01b8,x
         lda $1800+$01e0,x
         sta $0800+$01e0,x
         lda $1c00+$01e0,x
         sta $d800+$01e0,x
         lda $1800+$0208,x
         sta $0800+$0208,x
         lda $1c00+$0208,x
         sta $d800+$0208,x
         lda $1800+$0230,x
         sta $0800+$0230,x
         lda $1c00+$0230,x
         sta $d800+$0230,x
         lda $1800+$0258,x
         sta $0800+$0258,x
         lda $1c00+$0258,x
         sta $d800+$0258,x
         lda $1800+$0280,x
         sta $0800+$0280,x
         lda $1c00+$0280,x
         sta $d800+$0280,x
         lda $1800+$02a8,x
         sta $0800+$02a8,x
         lda $1c00+$02a8,x
         sta $d800+$02a8,x
         lda $1800+$02d0,x
         sta $0800+$02d0,x
         lda $1c00+$02d0,x
         sta $d800+$02d0,x
         lda $1800+$02f8,x
         sta $0800+$02f8,x
         lda $1c00+$02f8,x
         sta $d800+$02f8,x
         lda $1800+$0320,x
         sta $0800+$0320,x
         lda $1c00+$0320,x
         sta $d800+$0320,x
         lda $1800+$0348,x
         sta $0800+$0348,x
         lda $1c00+$0348,x
         sta $d800+$0348,x
         lda $1800+$0370,x
         sta $0800+$0370,x
         lda $1c00+$0370,x
         sta $d800+$0370,x
         lda $1800+$0398,x
         sta $0800+$0398,x
         lda $1c00+$0398,x
         sta $d800+$0398,x
         lda $1800+$03c0,x
         sta $0800+$03c0,x
         lda $1c00+$03c0,x
         sta $d800+$03c0,x
         txa
         clc
         adc #$e8
         sta v1+1
         sta v2+1
         sta v3+1
         sta v4+1
         bcc u1

         lda #$08
         .byte $2c
u1       lda #$0b
         sta v2+2
         ora #$10
         sta v1+2
         cmp #$1b
         bcc u2
         lda #$1f
         .byte $2c
u2       lda #$1c
         sta v3+2
         cmp #$1f
         bcc u3
         lda #$db
         .byte $2c
u3       lda #$d8
         sta v4+2

v1       lda $1800
v2       sta $0800
v3       lda $1c00
v4       sta $d800

         jmp p1

p5
         tax
         lda #$00
         sta $0800,x
         sta $d800,x
         sta $0800+$28,x
         sta $d800+$28,x
         sta $0800+$50,x
         sta $d800+$50,x
         sta $0800+$78,x
         sta $d800+$78,x
         sta $0800+$a0,x
         sta $d800+$a0,x
         sta $0800+$c8,x
         sta $d800+$c8,x
         sta $0800+$f0,x
         sta $d800+$f0,x
         sta $0800+$0118,x
         sta $d800+$0118,x
         sta $0800+$0140,x
         sta $d800+$0140,x
         sta $0800+$0168,x
         sta $d800+$0168,x
         sta $0800+$0190,x
         sta $d800+$0190,x
         sta $0800+$01b8,x
         sta $d800+$01b8,x
         sta $0800+$01e0,x
         sta $d800+$01e0,x
         sta $0800+$0208,x
         sta $d800+$0208,x
         sta $0800+$0230,x
         sta $d800+$0230,x
         sta $0800+$0258,x
         sta $d800+$0258,x
         sta $0800+$0280,x
         sta $d800+$0280,x
         sta $0800+$02a8,x
         sta $d800+$02a8,x
         sta $0800+$02d0,x
         sta $d800+$02d0,x
         sta $0800+$02f8,x
         sta $d800+$02f8,x
         sta $0800+$0320,x
         sta $d800+$0320,x
         sta $0800+$0348,x
         sta $d800+$0348,x
         sta $0800+$0370,x
         sta $d800+$0370,x
         sta $0800+$0398,x
         sta $d800+$0398,x
         sta $0800+$03c0,x
         sta $d800+$03c0,x
p1
         inc n0+1
         inc n1+1
         lda n0+1
p7       cmp #$80
         bne p4
         cmp #$80
         bne p6
         lda #<p5
         ldx #>p5
         sta p2+1
         stx p2+2
         lda #$00
         sta p7+1
         sta p8+1
         lda #$28
         sta p9+1
         jmp p4
p6       lda #<p3
         ldx #>p3
         sta p2+1
         stx p2+2
         lda #$80
         sta p7+1
         sta p9+1
         lda #$01
         sta p8+1

p4       inc $d019
         lda #$2d
         ldx #<irq1
         ldy #>irq1
         jmp exit



Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
iAN CooG/HVSC
Exile/Anubis
bodd
psych
MagerValp/G★P
Viscid/Neoplasia/The..
Krill/Plush
Martin Piper
Youth
Elder0010/G★P
Black/Angels
Apollyon/ALD
Hobbit/Fairlight
Guests online: 127
Top Demos
1 13:37  (9.8)
2 Next Level  (9.8)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Layers  (9.6)
5 Copper Booze  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Mikael  (9.7)
4 Lobo  (9.7)
5 Archmage  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.14 sec.