| | spindizzy Account closed
Registered: Feb 2007 Posts: 18 |
Sinus waving Rasterbars
Hi gentlemen,
i'm trying to make some rasterbars which are moving on a sinus curve, but i'm not able to do this ;(, are ther perhaps code snippets tutorials which explain the sinus - effect on rasterbars or perhaps you can help me, here is my code :
!to "sinus.prg",cbm
*= $0800
!byte $00,$0c,$08,$0a,$00,$9e,$32,$31,$32,$38,$00,$00,$00,$00
*=$0850
jsr kopieren
sei ;2
lda #$7f ; 2
sta $dc0d ;4
lda $dc0d ;4
lda #$32 ;2
sta $d012 ;4
lda $d011 ;4
and #$7f ;2
sta $d011 ;4
lda #$01 ;2
sta $d01a ;4
ldx #<irq ;2
ldy #>irq ;2
stx $0314 ;4
sty $0315 ;4
lda #147
jsr $ffd2
cli ;2
rti ;6
irq
dec $d019 ;4
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldy #$00
.loop1 ldx #$08
.loop2 lda $1200 ,y ;4
sta $d020 ;4
sta $d021 ;4
iny ;2
dex 2
beq .loop1 ;3
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
nop ;2
cpy #$47 ;2
bne .loop2 ;3
lda #$00 ;2
sta $d020 ;4
lda #$00 ;2
sta $d021 ;4
;-----------------------
lda #$00
sta $1500
ldx #$05
label1 lda $1400
sta $1600
ldy #$0e
label2 lda $0f00,y
sta $1200,y
dey
bpl label2
lda $1500
clc
adc #$0c
sta $1500
dex
bne label1
lda $1700
clc
adc #$03
sta $1700
jmp $ea81
kopieren ldx #$00
.copy lda $0f00,x
sta $1200,x
inx
bpl .copy
rts
*=$0f00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $02, $02, $01, $02, $02, $02, $0a, $0a
!byte $02, $0a, $0a, $0a, $07, $07, $0a, $07
!byte $07, $01, $01, $07, $01, $01, $01, $01
!byte $07, $01, $01, $07, $07, $0a, $07, $07
!byte $0a, $0a, $0a, $02, $0a, $0a, $02, $02
!byte $02, $01, $02, $02, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $06, $0e, $03, $01, $03, $0e, $06, $00
*=$1400
!byte $00,$00,$00,$00,$00,$01,$02,$02
!byte $03,$04,$05,$07,$08,$09,$0b,$0c
!byte $0e,$10,$12,$14,$16,$18,$1a,$1c
!byte $1e,$21,$23,$25,$28,$2a,$2d,$2f
!byte $32,$34,$36,$39,$3b,$3e,$40,$42
!byte $45,$47,$49,$4b,$4d,$4f,$51,$53
!byte $55,$57,$58,$5a,$5b,$5c,$5e,$5f
!byte $60,$61,$61,$62,$63,$63,$63,$63
!byte $63,$63,$63,$63,$63,$62,$61,$61
!byte $60,$5f,$5e,$5c,$5b,$5a,$58,$57
!byte $55,$53,$51,$4f,$4d,$4b,$49,$47
!byte $45,$42,$40,$3e,$3b,$39,$36,$34
!byte $31,$2f,$2d,$2a,$28,$25,$23,$21
!byte $1e,$1c,$1a,$18,$16,$14,$12,$10
!byte $0e,$0c,$0b,$09,$08,$07,$05,$04
!byte $03,$02,$02,$01,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$01,$02,$02
!byte $03,$04,$05,$07,$08,$09,$0b,$0c
!byte $0e,$10,$12,$14,$16,$18,$1a,$1c
!byte $1e,$21,$23,$25,$28,$2a,$2d,$2f
!byte $32,$34,$36,$39,$3b,$3e,$40,$42
!byte $45,$47,$49,$4b,$4d,$4f,$51,$53
!byte $55,$57,$58,$5a,$5b,$5c,$5e,$5f
!byte $60,$61,$61,$62,$63,$63,$63,$63
!byte $63,$63,$63,$63,$63,$62,$61,$61
!byte $60,$5f,$5e,$5c,$5b,$5a,$58,$57
!byte $55,$53,$51,$4f,$4d,$4b,$49,$47
!byte $45,$42,$40,$3e,$3b,$39,$36,$34
!byte $31,$2f,$2d,$2a,$28,$25,$23,$21
!byte $1e,$1c,$1a,$18,$16,$14,$12,$10
!byte $0e,$0c,$0b,$09,$08,$07,$05,$04
!byte $03,$02,$02,$01,$00,$00,$00,$00
Many, many thanx
;)
Spindizzy |
|
... 10 posts hidden. Click here to view all posts.... |
| | Mace
Registered: May 2002 Posts: 1799 |
Damn hard to read, unformatted code with hard addresses instead of labels :P
request please use
the [ code ] UBB-codes
to format
your code
|
| | SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
this is the biggest and worst sinus raster routine i have ever seen :) |
| | Mace
Registered: May 2002 Posts: 1799 |
The CSDb way of teaching in a nutshell:
Quoting Oswaldah getting better, altho still messy
Quoting MaceDamn hard to read, unformatted code with hard addresses instead of labels
Quoting RambonesThis is the biggest and worst sinus raster routine i have ever seen
:D
|
| | Conrad
Registered: Nov 2006 Posts: 849 |
Here's a cleaned up version of the code (ACME).
Hope it makes more sense now :-)
EDIT: the text supposed to have tabs to make the layout better, but looks like it hasn't turned out good on this forum :D
!to "sinus.prg",cbm
*= $0800
!byte $00,$0c,$08,$0a,$00,$9e,$32,$31,$32,$38,$00,$00,$00,$00
*=$0850
jsr kopieren
sei ;2
lda #$7f ; 2
sta $dc0d ;4
lda $dc0d ;4
lda #$32 ;2
sta $d012 ;4
lda $d011 ;4
and #$7f ;2
sta $d011 ;4
lda #$01 ;2
sta $d01a ;4
ldx #<irq ;2
ldy #>irq ;2
stx $0314 ;4
sty $0315 ;4
lda #147
jsr $ffd2
cli ;2
rti ;6
irq
dec $d019 ;4
!for I, 12 { nop } ;2 * 12
ldy #$00
.loop1
ldx #$08
.loop2
lda colours_show ,y ;4
sta $d020 ;4
sta $d021 ;4
iny ;2
dex ;2
beq .loop1 ;3
!for I, 20 { nop } ;2 * 20
colourbar_lines
cpy #$47 ;2
bne .loop2 ;3
lda #$00 ;2
sta $d020 ;4
lda #$00 ;2
sta $d021 ;4
;----- and now, the sinus thingy...
clc
sinus_pointer_1
ldx #$00
lda sinus_table,x
sinus_pointer_2
ldx #$00
adc sinus_table,x
tay
clc
ldx #$00
sinus_loop
lda colours_raw,y
sta colours_show,x
iny
cpy colourbar_lines+1
bcc sinus_skip
beq sinus_skip
tya
sbc colourbar_lines+1
tay
clc
sinus_skip
inx
cpx colourbar_lines+1
bne sinus_loop
lda sinus_pointer_1+1
clc
adc #$01
sta sinus_pointer_1+1
lda sinus_pointer_2+1
clc
adc #$02
sta sinus_pointer_2+1
jmp $ea81
kopieren
ldx #$00
.copy
lda colours_raw,x
sta colours_show,x
inx
bpl .copy
rts
*=$0f00
colours_raw
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $02, $02, $01, $02, $02, $02, $0a, $0a
!byte $02, $0a, $0a, $0a, $07, $07, $0a, $07
!byte $07, $01, $01, $07, $01, $01, $01, $01
!byte $07, $01, $01, $07, $07, $0a, $07, $07
!byte $0a, $0a, $0a, $02, $0a, $0a, $02, $02
!byte $02, $01, $02, $02, $00, $00, $00, $00
!byte $00, $00, $00, $00, $00, $00, $00, $00
!byte $06, $0e, $03, $01, $03, $0e, $06, $00
*=$1200
colours_show ;This is where the bar are displayed on screen
*=$1400
sinus_table
!byte $00,$00,$00,$00,$00,$01,$02,$02
!byte $03,$04,$05,$07,$08,$09,$0b,$0c
!byte $0e,$10,$12,$14,$16,$18,$1a,$1c
!byte $1e,$21,$23,$25,$28,$2a,$2d,$2f
!byte $32,$34,$36,$39,$3b,$3e,$40,$42
!byte $45,$47,$49,$4b,$4d,$4f,$51,$53
!byte $55,$57,$58,$5a,$5b,$5c,$5e,$5f
!byte $60,$61,$61,$62,$63,$63,$63,$63
!byte $63,$63,$63,$63,$63,$62,$61,$61
!byte $60,$5f,$5e,$5c,$5b,$5a,$58,$57
!byte $55,$53,$51,$4f,$4d,$4b,$49,$47
!byte $45,$42,$40,$3e,$3b,$39,$36,$34
!byte $31,$2f,$2d,$2a,$28,$25,$23,$21
!byte $1e,$1c,$1a,$18,$16,$14,$12,$10
!byte $0e,$0c,$0b,$09,$08,$07,$05,$04
!byte $03,$02,$02,$01,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$01,$02,$02
!byte $03,$04,$05,$07,$08,$09,$0b,$0c
!byte $0e,$10,$12,$14,$16,$18,$1a,$1c
!byte $1e,$21,$23,$25,$28,$2a,$2d,$2f
!byte $32,$34,$36,$39,$3b,$3e,$40,$42
!byte $45,$47,$49,$4b,$4d,$4f,$51,$53
!byte $55,$57,$58,$5a,$5b,$5c,$5e,$5f
!byte $60,$61,$61,$62,$63,$63,$63,$63
!byte $63,$63,$63,$63,$63,$62,$61,$61
!byte $60,$5f,$5e,$5c,$5b,$5a,$58,$57
!byte $55,$53,$51,$4f,$4d,$4b,$49,$47
!byte $45,$42,$40,$3e,$3b,$39,$36,$34
!byte $31,$2f,$2d,$2a,$28,$25,$23,$21
!byte $1e,$1c,$1a,$18,$16,$14,$12,$10
!byte $0e,$0c,$0b,$09,$08,$07,$05,$04
!byte $03,$02,$02,$01,$00,$00,$00,$00
|
| | raven Account closed
Registered: Jan 2002 Posts: 137 |
Just a small note, might be irrelevant to this prog:
dec $d019 ;4 <-- if this is supposed to be a cycle count,
it is wrong.
DEC/INC $xxxx takes 6 cycles |
| | Mace
Registered: May 2002 Posts: 1799 |
@ CRD: since you missed it the first time I posted it, I will post it in ALL CAPS NOW:
USE [ CODE ] {insert code here} [ /CODE ]
And your tabs are there again ;-) |
| | Oswald
Registered: Apr 2002 Posts: 5094 |
time to add proper irq set up code & explanation to codebase64.... +stable irq, etc etc... |
| | spindizzy Account closed
Registered: Feb 2007 Posts: 18 |
Many many Thanx,
@CRD, thx for the code, now i'm trying to understand it ;) !
Thanx to everybody and i will now always use ()
;)
Spindizzy |
| | spindizzy Account closed
Registered: Feb 2007 Posts: 18 |
i mean formatted Code !
;)
Spindizzy |
| | Danzig
Registered: Jun 2002 Posts: 440 |
not to forget that jmp$ea81 is teh shyte... use jmp$ea7e instead for $dc0d...
or even better, don't use irq at all for just some crappy moving rastersbars :D |
Previous - 1 | 2 - Next | |