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 > 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..
 
... 590 posts hidden. Click here to view all posts....
 
2011-12-13 12:15
Conjuror

Registered: Aug 2004
Posts: 168
Thanks Slammer that will help heaps.

So tempted to work the other way around and make JAVA spit out Kick Assembler script and ASM, but then I live in JAVA world all day.

Quote:
coding is always fun :)
Says the game programmer. Well coding is always fun, programming not always.
2011-12-29 09:14
Style

Registered: Jun 2004
Posts: 498
Ive asked this once before, and found some workaround at the time that Ive forgotten, but I lost my kickass libs and had to revert to ca65 again - and now, once again, Im converting to kickass ;)

So... the question once again - if I have a macro, how do I tell if the parameters were passed or not? ie, can I implement nonmandatory parameters?

thanks
2011-12-29 21:27
Slammer

Registered: Feb 2004
Posts: 416
Hi Style

Normal macros have to have the right number of arguments.

Pseudocommands can have empty parameters
2011-12-30 03:18
Style

Registered: Jun 2004
Posts: 498
any chance you can overload macros? :)

2011-12-30 17:02
Slammer

Registered: Feb 2004
Posts: 416
No, not at the moment.

Supplying too few parameters for a macros (like you can on pseudocommands) and setting the parameter to null when left out is possible. I left it out to avoid too much confusion when users supply to few arguments by mistake (Clearer errror messages vs flexibility) - If flexibility is in great demand, i'll open up that feature.

Since its a weakly typed script language something like the following is kind of against that nature of the language:

.macro myMacro(NumberValue x) {
  //do something
}

.macro myMacro(String x) {
  //do something else
}


If people miss this(?), it can be made possible by a type() function on objects:

.macro myMacro(x) {
  if (x.type()==NUMBERVALUE) :myMacro_value()
  else (x.type()==STRING) :myMacro_string()
  else .error("Unkown Type")

 

.macro myMacro_value(x) {
  //do something 
}

.macro myMacro_string(x) {
  //do something else
}



Btw. Can you give an example of where you will use this feature.
2011-12-31 04:40
Style

Registered: Jun 2004
Posts: 498
yeh, on ca65 I had a macro, next_irq, which accepted conditional parameters of the address and raster position. If you didnt provide them, it merely dec $d019 (ie, there is only 1 IRQ)....

small point I know, but like I said Im trying to convert sources over the kickass.
2011-12-31 11:04
Slammer

Registered: Feb 2004
Posts: 416
Then i suggest you use pseudo commands. Here is an example of how to do:
// Use it like this
         :irqEnd #$60 ; #irq2

// The macro
.pseudocommand irqEnd nextIrqYpos ; nextIrq ; extraArg {
	.if (nextIrqYpos.getType()!=AT_NONE) {
		:mov nextIrqYpos ; $d012
	}	
	.if (nextIrq.getType()!=AT_NONE) {
		:mov16 nextIrq ; $fffe
	}	
	.if (SAVE01==extraArg.getValue()) {
		:mov _ds_irq01 ; $01
	}
	lda _ds_irqa
	ldx _ds_irqx
	ldy _ds_irqy
	rti
}


The above have optional parameters for next ypos, next irq address, and an option to save $01. (The mov commands are 'pc style' pseudo commands that moves data)
2012-02-04 13:45
Slammer

Registered: Feb 2004
Posts: 416
Conjuror: Finally found some time to make a new release. Made the following functions on user defined structs:
getStructName() - returns the structure name
getNoOfFields() - returns the number of defined fields
getFieldNames() - returns a list of field names
get(fieldName) - returns a field value by field name.
get(index)     - returns a field value by field index 
set(index, value) - sets a field by field name
set(fieldName, value) - sets a fields by field index

2012-02-05 02:36
Conjuror

Registered: Aug 2004
Posts: 168
Slammer,

Great work! thanks. This will really help with more flexible code creation.

Nice to see the ternary operator in there too.

2012-02-08 12:56
McKrackeN

Registered: Feb 2011
Posts: 20
Hey ppl! I have a newbie question: is there a way to use constants inside a macro?

For instance, I need to be able to do something like this:


.const MyConst = $d012

.macro myMacro(val)
{
        ldy #val
	sty MyConst
}


But I get an error when compiling.

Thanks in advance! :)
Previous - 1 | ... | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ... | 60 - 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
iAN CooG/HVSC
MuZZa/The Codeblasters
Asphodel
psych
sln.pixelrat
Guests online: 68
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 Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

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