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


Forums > C64 Coding > ACME, modify argument of macro (speedcode generator)
2018-02-13 23:21
Golara

Registered: Jan 2018
Posts: 60
ACME, modify argument of macro (speedcode generator)

I'm trying to code a speedcode generator, most of this code is just nops and timed sta/sty for opening the borders. I came up with such macros:

!macro MACRO_fill_nops .count, .addr{
ldx #.count
lda $ea ; nop
-:
sta $.addr,x
dex
bpl -
}
;==============
!macro MACRO_copy_table .count .src .dst{
ldx #.count
-:
lda .src,x
sta .dst,x
dex
bpl -
}
;==============
irq_line_48_table1:
!byte $9a,$a2,$06,$ca,$d0,$fd,$ea,$a9
!byte $00,$8d,$1d,$d0,$8d,$1c,$d0,$24
!byte $ea,$a9,$30,$cd,$12,$d0,$f0,$00
irq_line_48_table2:
!byte $24,$EA,$AD,$16,$D0,$29,$77,$A8
!byte $A2,$00,$AD,$16,$D0,$8C,$16,$D0
!byte $9D,$16,$D0,$8C,$16,$D0,$EA,$8D
!byte $16,$D0
irq_line_48_table3:
!byte $8c,$16,$d0,$ea,$8d,$16,$d0
;-----------------------------


Now I want to call these 2 macros in a loop like this
ldy #7
-:
+MACRO_fill_nops 20, $1391
+MACRO_copy_table 6, irq_line_48_table3, $13a6

;MODIFY THE ARGUMENTS OF THE MACRO HERE
dey
bne -


I guess this could be done with labels like
ldy #7
-:
modme_1:
+MACRO_fill_nops 20, $1391
modme_2:
+MACRO_copy_table 6, irq_line_48_table3, $13a6

; modify modme_1 + 5/6 to change the address
; modify modme_2 + 6/7 to change the address
dey
bne -


but I'm just wondering if there's a cleaner way.
(btw is this what speedcode generator is ? I'm just going with my gut instinct)
2018-02-14 00:08
Oswald

Registered: Apr 2002
Posts: 4231
you can just type out the code you put into .byte, easyer to read and modify :)

most guys do this by having it done completely inside the compiler, so they dont even copy the code by "hand" as you do.

I am native nazi, and do this kind of stuff with the 6510 inside the 64, not on compile time.

I do this by doing a copy loop using (zp),y adressing and modding the code sample (that is copyed around) as needed before the copy. if speed is needed I even unroll the copy loop into lda #opcode sta (),y statements.
2018-02-14 00:15
Golara

Registered: Jan 2018
Posts: 60
That's interesting, thanks. This is still for that part i showed in the other thread. I've made big improvments since then... 2x2 sideborder scroller, multi color logos doing tech-tech, 2x speed sid tune, it's going good. Just raw code with some data repeating is about 35 kb, with exomiser it's 15kb. I wonder how much lower I can take it with generators.
2018-02-14 01:01
Oswald

Registered: Apr 2002
Posts: 4231
a lot lower it should be. a few generators shouldnt take more than a couple of hundreds bytes.


here is how I generate speedcode fur the radial blur on ditch, messy at first sight, but doesnt need 15kb :)

keblurspd1 lda #<blurspd1
sta fc
lda #>blurspd1
sta fd

lda #25
sta y
sta resety+1
lda #$ff
sta endy+1
lda qdec
sta ydir

lda #32
sta x
lda #$ff
sta endx+1
lda qdec
sta xdir
jmp start

makeblurspd2
lda #<blurspd2
sta fc
lda #>blurspd2
sta fd

lda #25
sta y
sta resety+1
lda #$ff
sta endy+1
lda qdec
sta ydir

lda #33
sta x
lda #64
sta endx+1
lda qinc
sta xdir
jmp start

makeblurspd3 lda #<blurspd3
sta fc
lda #>blurspd3
sta fd

lda #26
sta y
sta resety+1
lda #50
sta endy+1
lda qinc
sta ydir

lda #32
sta x
lda #$ff
sta endx+1
lda qdec
sta xdir
jmp start

makeblurspd4 lda #<blurspd4
sta fc
lda #>blurspd4
sta fd

lda #26
sta y
sta resety+1
lda #50
sta endy+1
lda qinc
sta ydir

lda #33
sta x
lda #64
sta endx+1
lda qinc
sta xdir
jmp start



start

loopx ldy #$00
lda q4
sta (fc),y
iny
lda x
clc
adc #zpbasex
sta (fc),y
iny
tya
clc
adc fc
sta fc
bcc +
inc fd
+


loopy
lda y
lsr
tay
lda mul64l,y
clc
adc x
sta src+1
lda mul64h,y
adc #$00
sta src+2

src lda $1000 ;get original pixel value
sta q1+2
;jmp *
lda y
asl
clc
adc #zpbasey
sta q0+1

ldx x
ldy y
lda mul6xl,x
clc
adc mul6yl,y
sta q2+1
lda mul6xh,x
adc mul6yh,y
sta q2+2

.comment
lda x
and #%00000001
tax
lda q2+1
clc
adc xadd,x
sta q2+1
bcc *+5
inc q2+2
.endc

ldy #$00
- lda q0,y
sta (fc),y
iny
cpy #q4-q0
bne -

tya
clc
adc fc
sta fc
bcc +
inc fd
+

ydir inc y
lda y
endy cmp #50
bne loopy

resety lda #$00
sta y

xdir inc x
lda x
endx cmp #64
beq +
jmp loopx
+
ldy #$00
lda #$60
sta (fc),y
rts

qinc inc $02
qdec dec $02


q0 lax ($02),y ;6
q1 lda $10e0,x ;10
q2 sta $1000 ;14
q3

q4 ldy $02

xadd .byte 1,2

mul6xl .for ue=0,ue<32,ue=ue+1
.byte <(ue*6)+1
.byte <(ue*6)+2
.next

mul6xh .for ue=0,ue<32,ue=ue+1
.byte >(ue*6)+1
.byte >(ue*6)+2
.next

mul6yl .for ue=0,ue<50,ue=ue+1
.byte <(ue*192)+c2p
.next

mul6yh .for ue=0,ue<50,ue=ue+1
.byte >(ue*192)+c2p
.next
2018-02-14 02:39
Groepaz

Registered: Dec 2001
Posts: 8471
i'd prototype the routine using for-loops and conditional assembly (not macros) - and when it works and you are sure you wont modify it anymore, basically do the same thing but with small snippets you copy and patch as needed.
2018-02-14 17:22
JackAsser

Registered: Jun 2002
Posts: 1281
Quoting Groepaz
i'd prototype the routine using for-loops and conditional assembly (not macros) - and when it works and you are sure you wont modify it anymore, basically do the same thing but with small snippets you copy and patch as needed.

Eggsacktly
2018-02-14 18:25
Golara

Registered: Jan 2018
Posts: 60
Quote: i'd prototype the routine using for-loops and conditional assembly (not macros) - and when it works and you are sure you wont modify it anymore, basically do the same thing but with small snippets you copy and patch as needed.

Yea yea that's what I do, I consider my part done and now i'm replacing all the hand writen code with generators.
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
sebalozlepsi
Board Rider/Commodor..
Guests online: 37
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Comaland 100%  (9.6)
6 We Come in Peace  (9.6)
7 Lunatico  (9.6)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Dawnfall V1.1  (9.5)
2 Synthesis  (9.5)
3 FMX Music Demo  (9.5)
4 Pandemoniac Part 2 o..  (9.5)
5 Daah, Those Acid Pil..  (9.5)
6 Treu Love [reu]  (9.5)
7 Merry Xmas 2017  (9.4)
8 Dawnfall  (9.4)
9 Gubbdata 2017 Invite  (9.3)
10 SidRok  (9.3)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.9)
3 Irata  (9.8)
4 Wotnau  (9.7)
5 MWS  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.956 sec.