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 > Kick Assembler Thread 2
2009-07-21 17:20
Slammer

Registered: Feb 2004
Posts: 416
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 595 posts hidden. Click here to view all posts....
 
2023-08-09 21:51
Frostbyte

Registered: Aug 2003
Posts: 166
Quote: Instead of using a bunch of labels, you can create a list to keep track of the addresses, and then use that list to reach them. Like this:

.var ldas = List()

.macro the_macro_that_creates_the_code() {
.eval ldas.add(* + 1)
lda #0
sta $d020
}

Then, further down in the code:

.macro the_macro_that_refers_to_the_created_code() {
.for (var i = 0; i < ldas.size(); i++) {
lda colors + i,x
sta ldas.get(i)
}
}


Ahhh of course, brilliant! Thank you! I haven't tried it yet, but I can already see it solves my problem. :)
2023-08-09 22:35
Slammer

Registered: Feb 2004
Posts: 416
This is probably one of the most asked questions. There are different ways to handle these kind of cases one of them is shown by Trident. Let me point you to another feature that solves it quite nicely.

Normally, when you want label1, label2, etc. the labels are inside a loop, like:
	spriteLoop: .for (var i=0; i<8; i++) {
		lda data: #0    // <- Fancy inbetween label declaration so you dont need +1
		sta $07f8+i
	}

You can now use the 'spriteLoop' label to access the 'data' labels of the different iterations of the loop like this:
	lda #0
	sta spriteLoop[0].data  // Sprite 0   
	sta spriteLoop[1].data  // Sprite 1   
	sta spriteLoop[2].data  // Sprite 2
	...   

	// Or simply .for (var i=0; i<8; i++) sta spriteLoop[i].data

If you want to do a table with the addresses, simply:
	addrTable: .fill  8, <spriteLoop[i].data  

You can access the labels of an executed macros by putting a label in front of the execution, just like we did with the .for loop.
2023-08-09 22:40
Slammer

Registered: Feb 2004
Posts: 416
With regards to the dicussion earlier in the thread. Several years ago I moved the main feedback/support channel of Kick Assembler to the following facebook group:

https://www.facebook.com/groups/RetroAssembler

This was to ensure a forum were the discussion where not interupted by other things. You are welcome to join regardless of which assembler you are using.

(Please notice that I do not visit this CSDb thread often).
2023-08-10 12:49
Frostbyte

Registered: Aug 2003
Posts: 166
Quote: With regards to the dicussion earlier in the thread. Several years ago I moved the main feedback/support channel of Kick Assembler to the following facebook group:

https://www.facebook.com/groups/RetroAssembler

This was to ensure a forum were the discussion where not interupted by other things. You are welcome to join regardless of which assembler you are using.

(Please notice that I do not visit this CSDb thread often).


Yesterday I sent a request to join that group, but it's still pending. :)
2023-08-10 12:54
Frostbyte

Registered: Aug 2003
Posts: 166
Quote: This is probably one of the most asked questions. There are different ways to handle these kind of cases one of them is shown by Trident. Let me point you to another feature that solves it quite nicely.

Normally, when you want label1, label2, etc. the labels are inside a loop, like:
	spriteLoop: .for (var i=0; i<8; i++) {
		lda data: #0    // <- Fancy inbetween label declaration so you dont need +1
		sta $07f8+i
	}

You can now use the 'spriteLoop' label to access the 'data' labels of the different iterations of the loop like this:
	lda #0
	sta spriteLoop[0].data  // Sprite 0   
	sta spriteLoop[1].data  // Sprite 1   
	sta spriteLoop[2].data  // Sprite 2
	...   

	// Or simply .for (var i=0; i<8; i++) sta spriteLoop[i].data

If you want to do a table with the addresses, simply:
	addrTable: .fill  8, <spriteLoop[i].data  

You can access the labels of an executed macros by putting a label in front of the execution, just like we did with the .for loop.


Nice! As in my scenario I don't know how many labels I'll end up with, I suppose in the second loop I could also iterate while i < spriteLoop.size()? (in other words, compiler considers spriteLoop as an array or list?)
Previous - 1 | ... | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 - 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
Krill/Plush
Guests online: 134
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 Wafer Demo  (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 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

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