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


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

Registered: Jan 2018
Posts: 212
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-13 23:08
Oswald

Registered: Apr 2002
Posts: 5017
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-13 23:15
Golara
Account closed

Registered: Jan 2018
Posts: 212
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 00:01
Oswald

Registered: Apr 2002
Posts: 5017
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 01:39
chatGPZ

Registered: Dec 2001
Posts: 11100
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 16:22
JackAsser

Registered: Jun 2002
Posts: 1987
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 17:25
Golara
Account closed

Registered: Jan 2018
Posts: 212
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
Magic/Nah-Kolor
zscs
Grue/Extend
Guests online: 69
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 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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