mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-03 12:07:26 +00:00
Fixed scope comparison.
This commit is contained in:
parent
3d4d114522
commit
e09a0718d0
@ -448,7 +448,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
|
|||||||
return statementKickAsm;
|
return statementKickAsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inline KickAssembler code. */
|
/** Inline KickAssembler (can be either inline code or inline data initialization). */
|
||||||
static class KickAsm {
|
static class KickAsm {
|
||||||
/** KickAssembler code. */
|
/** KickAssembler code. */
|
||||||
private final String kickAsmCode;
|
private final String kickAsmCode;
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
package dk.camelot64.kickc.passes;
|
package dk.camelot64.kickc.passes;
|
||||||
|
|
||||||
import dk.camelot64.kickc.model.CompileError;
|
import dk.camelot64.kickc.model.CompileError;
|
||||||
import dk.camelot64.kickc.model.ControlFlowBlock;
|
|
||||||
import dk.camelot64.kickc.model.Program;
|
import dk.camelot64.kickc.model.Program;
|
||||||
import dk.camelot64.kickc.model.statements.Statement;
|
|
||||||
import dk.camelot64.kickc.model.statements.StatementLValue;
|
|
||||||
import dk.camelot64.kickc.model.symbols.Variable;
|
import dk.camelot64.kickc.model.symbols.Variable;
|
||||||
import dk.camelot64.kickc.model.values.ScopeRef;
|
import dk.camelot64.kickc.model.values.ScopeRef;
|
||||||
import dk.camelot64.kickc.model.values.SymbolRef;
|
|
||||||
import dk.camelot64.kickc.model.values.VariableRef;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that no local variables with arrays and hard-coded addresses exist
|
* Checks that no local variables with arrays and hard-coded addresses exist
|
||||||
@ -22,7 +17,7 @@ public class Pass1AssertNoLocalAddressArray extends Pass1Base {
|
|||||||
@Override
|
@Override
|
||||||
public boolean step() {
|
public boolean step() {
|
||||||
for(Variable variable : getScope().getAllVars(true)) {
|
for(Variable variable : getScope().getAllVars(true)) {
|
||||||
if(!ScopeRef.ROOT.equals(variable.getScope()) && variable.isArray() && variable.getMemoryAddress()!=null)
|
if(!ScopeRef.ROOT.equals(variable.getScope().getRef()) && variable.isArray() && variable.getMemoryAddress()!=null)
|
||||||
throw new CompileError("Error! Local array variables with __address() not allowed. "+variable.toString(getProgram()));
|
throw new CompileError("Error! Local array variables with __address() not allowed. "+variable.toString(getProgram()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,13 +7,13 @@ __address(0x0c00) byte SPRITE[] = kickasm(resource "balloon.png") {{
|
|||||||
.byte pic.getSinglecolorByte(x,y)
|
.byte pic.getSinglecolorByte(x,y)
|
||||||
}};
|
}};
|
||||||
|
|
||||||
byte* const SCREEN= $400;
|
char* const SCREEN= 0x400;
|
||||||
byte* const SPRITES_ENABLE = $d015;
|
char* const SPRITES_ENABLE = 0xd015;
|
||||||
byte* const SPRITES_XPOS = $d000;
|
char* const SPRITES_XPOS = 0xd000;
|
||||||
byte* const SPRITES_YPOS = $d001;
|
char* const SPRITES_YPOS = 0xd001;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
*(SCREEN+$3f8) = (byte)((word)SPRITE/$40);
|
*(SCREEN+0x3f8) = (char)((unsigned int)SPRITE/$40);
|
||||||
*SPRITES_ENABLE = 1;
|
*SPRITES_ENABLE = 1;
|
||||||
*SPRITES_XPOS = 100;
|
*SPRITES_XPOS = 100;
|
||||||
*SPRITES_YPOS = 100;
|
*SPRITES_YPOS = 100;
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
.pc = $801 "Basic"
|
.pc = $801 "Basic"
|
||||||
:BasicUpstart(main)
|
:BasicUpstart(main)
|
||||||
.pc = $80d "Program"
|
.pc = $80d "Program"
|
||||||
.label SPRITE = $c00
|
|
||||||
.label SCREEN = $400
|
.label SCREEN = $400
|
||||||
.label SPRITES_ENABLE = $d015
|
.label SPRITES_ENABLE = $d015
|
||||||
.label SPRITES_XPOS = $d000
|
.label SPRITES_XPOS = $d000
|
||||||
.label SPRITES_YPOS = $d001
|
.label SPRITES_YPOS = $d001
|
||||||
// kickasm
|
|
||||||
main: {
|
main: {
|
||||||
// *(SCREEN+$3f8) = (byte)((word)SPRITE/$40)
|
// *(SCREEN+0x3f8) = (char)((unsigned int)SPRITE/$40)
|
||||||
lda #SPRITE/$40
|
lda #$ff&SPRITE/$40
|
||||||
sta SCREEN+$3f8
|
sta SCREEN+$3f8
|
||||||
// *SPRITES_ENABLE = 1
|
// *SPRITES_ENABLE = 1
|
||||||
lda #1
|
lda #1
|
||||||
@ -23,8 +21,9 @@ main: {
|
|||||||
// }
|
// }
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
.pc = SPRITE "SPRITE"
|
.pc = $c00 "SPRITE"
|
||||||
.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
|
SPRITE:
|
||||||
|
.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
|
||||||
.for (var y=0; y<21; y++)
|
.for (var y=0; y<21; y++)
|
||||||
.for (var x=0;x<3; x++)
|
.for (var x=0;x<3; x++)
|
||||||
.byte pic.getSinglecolorByte(x,y)
|
.byte pic.getSinglecolorByte(x,y)
|
||||||
|
Loading…
Reference in New Issue
Block a user