Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Charset animation problem
2007-10-14 10:39
Richard

Registered: Dec 2001
Posts: 619
Charset animation problem

Hi there.

I known how to animate a charset that contains 8 charsets. Which is something like this:

CHARANIM	INC ANIMPOINTER
			LDA ANIMPOINTER
			CMP #$08
			BNE ENDANIM
			LDA #$00
			STA ANIMPOINTER
			JSR ANIMATE
ENDANIM	RTS
ANIMATE	LDX #$00
WRAPCHR	LDA $0A00,X
			STA $0A40,X
			INX
			CPX #$08
			BNE WRAPCHR
			LDX #$00
WRAPCHR2	LDA $0A08,X
			STA $0A00,X
			INX
			CPX #$40
			BNE WRAPCHR2
			RTS



Easy eh? Unfortunately, I'm trying to animate a charset which somehow has a bigger animation. The animated chars are from $0910-$0a40. Please can you help me get an accurate animation for chars $0910-$0a40 (Putting $0a40 to $0910 and wrapping the frames for all the chars from that range :( ?
2007-10-14 11:14
Scout

Registered: Dec 2002
Posts: 1568
Animate a charset that contains 8 charsets?

Could you be more specific?

Maybe you can solve the problem using ROL's?
2007-10-14 11:26
Richard

Registered: Dec 2001
Posts: 619
Sorry, I must have worded it wrong.

I want to animate 39 chars starting from the first char (to be animated at $0910) and to the last char (to be animated at $0a40). :(

Therefore the animation should consist of 39 frames.
2007-10-14 12:45
Conrad

Registered: Nov 2006
Posts: 833
If you are viewing just ONE animated char on the screen (which i hope you are on about) that consists more than #$20 chars of animation (which goes over one full memory page) then you are better off reading char memory locations and storing it into a temporary char that is to be viewed on the screen, rather than wrapping the whole animation memory, saving a lot of raster-time.

Here something I coded up... I'm not too sure if it's 100% of what you are wanting though...
(subroutine)

	ldy #$07	;Number of lines per char - 1
	ldx #>$0910	;Animation memory (Hi-location) < $09-- >

AnimCounter
	lda #$00	;Where you store the current frame number
	asl
	asl
	asl
	bcc *+3
	inx
	stx $03
	clc
	adc #<$0910	;Animation memory (Lo-location) < $--10 >
	sta $02
	lda $03
	adc #$00
	sta $03

CharWrite	
	lda ($02),y
	sta $2000,y	;Memory of the animated char viewed on the screen
	dey
	bpl CharWrite
	
	ldy AnimCounter+1
	iny
	cpy #39		;Number of animation frames
	bne *+4
	ldy #$00
	sty AnimCounter+1
	rts


NOTE:
The statement "sta $2000,y" is the memory location of the char you want to view on the screen, so in this example, you need to view the "@" char and set $d018 to #$18 ($2000-$27ff).

The statement "cpy #39" is the number of frames you want animated.


Hope this helps a bit. Let me know.
2007-10-14 12:47
Laxity

Registered: Aug 2005
Posts: 459
I'm having a hard time understanding exactly what you're trying to do. Also I think the method you ultimately implement would depend on what the animated character is part of.. I guessing it a background thing, right?..

I understand this:

1. You want to animate 8 characters in the charset buffer.
2. The animation sequence is 39 frames long.

Is that correct?

Furthermore I understand that the 8 characters will be showing 8 instances of the same animation, with on frame difference from instance to instance (deducted from what I think the code snippet does). Is that correct?
2007-10-14 13:07
Richard

Registered: Dec 2001
Posts: 619
I want to animate all 39 characters in the character buffer, not 8 :(
2007-10-14 13:12
Conrad

Registered: Nov 2006
Posts: 833
Richard: when you mean "character buffer", do mean just one char? If so, then the code above with do just that!
2007-10-14 13:22
Richard

Registered: Dec 2001
Posts: 619
All 39 chars :)

Place $0910 to $0a40 and then keep pulling it through to $0910 again. This is so that the 39 chars I am using will animate.

Just like the way I do a colour washing routine that moves from the right of the screen, right over to the first byte.

eg.                    lda table1
                       sta table1+39
                       ldx #0
wrap                   lda table1+1,x
                       sta table1+0,x
                       inx
                       cpx #39
                       bne wrap

It is hard for me to explain, but I'm using chars $22 - $48. So char $22 gets copied to $48 and the chars $23 - $27 go back one char, and then repeat inside a loop. So that way I can get a visible char animation.
2007-10-14 13:26
iAN CooG

Registered: May 2002
Posts: 3136
The fastest way I can think of doing it is by using an unrolled loop, still takes lots of rastertime.
;---------------------------------------
; Animate some chars, unrolled loop
; ~6*8 lines of rastertime taken
; dasm used
; iAN CooG/HokutoForce
;---------------------------------------
charset    = $0800
scr        = $0400
charstart  = charset+[$22*8]
N_of_chars = 39
; 8 zp temp bytes
ztemp      = $49
;d018 value
ns         = >scr<<2
nc         = [>charset&$3f]>>2
v18        = [ns|nc]&$ff

debug      = 0
;---------------------------------------
    *=$1000
    sei
    jsr setmode
    jsr setirq
    cli
    jmp *
;---------------------------------------
animloop
    sta rsA+1
    stx rsX+1
    sty rsY+1

    inc $d019
    bit $2c2c
    bit $2c2c
    bit $2c2c
    bit $2c2c
    bit $2c2c
    bit $2c2c
    bit $2c2c
    nop
    inc $d020

;copy 1st element to ztemp
R SET 0
REPEAT 8
    lda [charstart+R]
    sta [ztemp    +R]
R SET R+1
REPEND
    inc $d020
;copy 2nd to 1st ... last to last-1
C SET 0
REPEAT [N_of_chars-1]
 R SET 0
 REPEAT 8
    lda [charstart+R+[[C+1]*8]]
    sta [charstart+R+[ C   *8]]
 R SET R+1
 REPEND
C SET C+1
REPEND
    inc $d020
;copy back ztemp to last
R SET 0
REPEAT 8
    lda [ztemp    +R]
    sta [charstart+R+[[N_of_chars-1]*8]]
R SET R+1
REPEND

    lda #0
    sta $d020

.if debug == 1
    ldx #5
delay
    bit $d011
    bmi *-3
    bit $d011
    bpl *-3
    dex
    bne delay
.endif
rsA lda #$ff
rsX ldx #$ff
rsY ldy #$ff
    rti

;---------------------------------------
setirq

    lda #>animloop
    sta $ffff
    lda #<animloop
    sta $fffe
    lda #$33
    sta $d012
    lda #$1b
    sta $d011
    lda #1
    sta $d019
    sta $d01a
    lda #$7f
    sta $dc0d
    lda $dc0d
    rts
;---------------------------------------
setmode

    lda #v18
    sta $d018

    lda #$32
    sta $01
    lda #$d0
    sta trc+2
    lda #>charset
    sta trc+5
    ldx #$00
    ldy #$08
trc
    lda $d000,x
    sta charset,x
    txa
    sta $0400,x
    inx
    bne trc
    inc trc+2
    inc trc+5
    dey
    bne trc

    lda #$35
    sta $01

    rts
;eof
2007-10-14 13:28
Richard

Registered: Dec 2001
Posts: 619
Correction:
It is hard for me to explain, but I'm using chars $22 - $48. So char $22 gets copied to $48 and the chars $23 - $47 go back one char, and then repeat inside a loop. So that way I can get a visible char animation.
2007-10-14 14:04
Conrad

Registered: Nov 2006
Posts: 833
I kind of understand what you're trying to accomplish here, which is to actually wrap char memory right around itself (like a sprite side-border scoller for example but instead rotates by 8 pixels (a char) at each frame) ... therefore it's not that hard to code - but i warn you, the bigger animation buffer you have, the more raster time is gonna be eaten up.
2007-10-14 16:33
Krill

Registered: Apr 2002
Posts: 2852
Do you really need to display all animation phases at the same time? In other words, can't you just copy the current phase to one character once every frame?
2007-10-14 16:50
Conrad

Registered: Nov 2006
Posts: 833
Quote: Do you really need to display all animation phases at the same time? In other words, can't you just copy the current phase to one character once every frame?

That's what I thought he was trying to ask, which is why I wasted some time writing that routine I posted a few hours ago.

I think Richard is saying that he wants to view more than one char on the screen which use the same animation data.

But again!- that routine i posted could be used MULTIPLE times to write animation to different individual chars of any set/bank if you think about it. Modifications need to be applied of course.
2007-10-14 17:04
Richard

Registered: Dec 2001
Posts: 619
Thanks for your help :)

I'm probably better off using less than 39 chars because of too much rastertime being used :(
2007-10-14 20:21
Krill

Registered: Apr 2002
Posts: 2852
39 chars * 8 bytes * 8 cycles / 63 cycles = about 40 rasterlines. Does not sound much to me.
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
Worrior1/W1 Producti..
Nith/TRIɅD
JEZ
digix
Mibri/ATL^MSL^PRX
Elder0010/G★P
wbochar
Adder/Triad
t0m3000/ibex-crew
Scrap/Genesis Project
Soya/Fairlight
Didi/Laxity
Aomeba/Artline Desig..
Brittle/Dentifrice^(?)
Grue/Extend
Iapetus/Algar../Cosine
Durandal
E$G/hOKUtO fOrcE
Guests online: 107
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (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 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Vincenzo  (9.8)
2 Rob Hubbard  (9.7)
3 Stinsen  (9.7)
4 Jeroen Tel  (9.6)
5 Linus  (9.6)

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