| |
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.... |
| |
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.
|
| |
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
|
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Hi Style
Normal macros have to have the right number of arguments.
Pseudocommands can have empty parameters |
| |
Style
Registered: Jun 2004 Posts: 498 |
any chance you can overload macros? :)
|
| |
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. |
| |
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.
|
| |
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) |
| |
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
|
| |
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.
|
| |
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 |