mirror of
https://github.com/irmen/prog8.git
synced 2024-12-25 08:29:25 +00:00
fixed for loop with step size >1
This commit is contained in:
parent
2f9eabeac7
commit
299d1bdab8
@ -1,10 +1,11 @@
|
|||||||
%import c64lib
|
|
||||||
%import c64utils
|
%import c64utils
|
||||||
%option force_output, enable_floats
|
%option enable_floats
|
||||||
|
|
||||||
|
|
||||||
~ spritedata $0a00 {
|
~ spritedata $0a00 {
|
||||||
%option force_output ; make sure the data appears in the program
|
; this memory block contains the sprite data
|
||||||
|
; it must start on an address aligned to 64 bytes.
|
||||||
|
%option force_output ; make sure the data in this block appears in the resulting program
|
||||||
|
|
||||||
ubyte[63] balloonsprite = [ %00000000,%01111111,%00000000,
|
ubyte[63] balloonsprite = [ %00000000,%01111111,%00000000,
|
||||||
%00000001,%11111111,%11000000,
|
%00000001,%11111111,%11000000,
|
||||||
@ -39,21 +40,22 @@
|
|||||||
c64.STROUT("balloon sprites!\n")
|
c64.STROUT("balloon sprites!\n")
|
||||||
c64.STROUT("...we are all floating...\n")
|
c64.STROUT("...we are all floating...\n")
|
||||||
|
|
||||||
c64.SPRPTR0 = $0a00//64
|
const uword sprite_address_ptr = $0a00 // 64 ; @todo " &balloonsprite // 64"
|
||||||
c64.SPRPTR1 = $0a00//64
|
c64.SPRPTR0 = sprite_address_ptr
|
||||||
c64.SPRPTR2 = $0a00//64
|
c64.SPRPTR1 = sprite_address_ptr
|
||||||
c64.SPRPTR3 = $0a00//64
|
c64.SPRPTR2 = sprite_address_ptr
|
||||||
c64.SPRPTR4 = $0a00//64
|
c64.SPRPTR3 = sprite_address_ptr
|
||||||
c64.SPRPTR5 = $0a00//64
|
c64.SPRPTR4 = sprite_address_ptr
|
||||||
c64.SPRPTR6 = $0a00//64
|
c64.SPRPTR5 = sprite_address_ptr
|
||||||
c64.SPRPTR7 = $0a00//64
|
c64.SPRPTR6 = sprite_address_ptr
|
||||||
|
c64.SPRPTR7 = sprite_address_ptr
|
||||||
|
|
||||||
for ubyte i in 0 to 7 {
|
for ubyte i in 0 to 7 {
|
||||||
@(SP0X+i*2) = 50+25*i
|
@(SP0X+i*2) = 50+25*i
|
||||||
@(SP0Y+i*2) = rnd()
|
@(SP0Y+i*2) = rnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
c64.SPENA = 255 ; enable all sprites
|
c64.SPENA = 255 ; enable all sprites
|
||||||
c64utils.set_rasterirq(51) ; enable animation
|
c64utils.set_rasterirq(51) ; enable animation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,16 +65,13 @@
|
|||||||
sub irq() {
|
sub irq() {
|
||||||
c64.EXTCOL--
|
c64.EXTCOL--
|
||||||
; float up & wobble horizontally
|
; float up & wobble horizontally
|
||||||
|
for ubyte i in 0 to 14 step 2 {
|
||||||
; @todo for loop with step 2 doesn't work
|
@(main.SP0Y+i)--
|
||||||
|
|
||||||
for ubyte i in 0 to 7 {
|
|
||||||
@(main.SP0Y+i+i)--
|
|
||||||
ubyte r = rnd()
|
ubyte r = rnd()
|
||||||
if r>208
|
if r>200
|
||||||
@(main.SP0X+i+i)++
|
@(main.SP0X+i)++
|
||||||
else if r<48
|
else if r<40
|
||||||
@(main.SP0X+i+i)--
|
@(main.SP0X+i)--
|
||||||
}
|
}
|
||||||
c64.EXTCOL++
|
c64.EXTCOL++
|
||||||
}
|
}
|
||||||
|
@ -3,61 +3,19 @@
|
|||||||
~ main {
|
~ main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
uword uw1 = 0
|
|
||||||
uword uw2 = $77ff
|
|
||||||
uword uw3 = $55aa
|
|
||||||
word w1 = 0
|
|
||||||
word w2 = $22ff
|
|
||||||
word w3 = $55aa
|
|
||||||
memory uword muw1 = $2000
|
|
||||||
memory uword muw2 = $3000
|
|
||||||
memory uword muw3 = $4000
|
|
||||||
memory word mw1 = $4100
|
|
||||||
memory word mw2 = $4200
|
|
||||||
memory word mw3 = $4300
|
|
||||||
|
|
||||||
uword[3] uwarr = $55aa
|
for ubyte j in 0 to 7 step 2 { ; @todo wrong bytecode generated!!
|
||||||
word[3] warr = $55aa
|
vm_write_num(j)
|
||||||
memory uword[3] muwarr = $4400
|
vm_write_char('\n')
|
||||||
memory word[3] mwarr = $4500
|
;c64scr.print_ub(j)
|
||||||
|
;c64.CHROUT('\n')
|
||||||
|
}
|
||||||
|
|
||||||
muw3 = $55aa
|
for ubyte j in 10 to 3 step -2 { ; @todo wrong bytecode generated!!
|
||||||
uwarr[0] = $55aa
|
vm_write_num(j)
|
||||||
uwarr[1] = $55aa
|
vm_write_char('\n')
|
||||||
uwarr[2] = $55aa
|
;c64scr.print_ub(j)
|
||||||
muwarr[0] = $55aa
|
;c64.CHROUT('\n')
|
||||||
muwarr[1] = $55aa
|
}
|
||||||
muwarr[2] = $55aa
|
|
||||||
mwarr[0] = $55aa
|
|
||||||
mwarr[1] = $55aa
|
|
||||||
mwarr[2] = $55aa
|
|
||||||
|
|
||||||
uw1 = uw2 + $55aa ;52649
|
|
||||||
c64scr.print_uw(uw1)
|
|
||||||
c64.CHROUT('\n')
|
|
||||||
|
|
||||||
uw1 = uw2 + uw3 ;52649
|
|
||||||
c64scr.print_uw(uw1)
|
|
||||||
c64.CHROUT('\n')
|
|
||||||
|
|
||||||
uw1 = uw2 + muw3 ;52649
|
|
||||||
c64scr.print_uw(uw1)
|
|
||||||
c64.CHROUT('\n')
|
|
||||||
|
|
||||||
; uw1 = uw2 + uwarr[2] ;52649
|
|
||||||
; c64scr.print_uw(uw1)
|
|
||||||
; c64.CHROUT('\n')
|
|
||||||
|
|
||||||
|
|
||||||
; w1 = w2 + $55aa ; 30889
|
|
||||||
; c64scr.print_w(w1)
|
|
||||||
; c64.CHROUT('\n')
|
|
||||||
; w1 = w2 + w3 ; 30889
|
|
||||||
; c64scr.print_w(w1)
|
|
||||||
; c64.CHROUT('\n')
|
|
||||||
;
|
|
||||||
; uwarr[2] = uwarr[1] + $55aa
|
|
||||||
; uwarr[2] = uwarr[1] + uw3
|
|
||||||
; uwarr[2] = uwarr[1] + uwarr[1]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1802,7 @@ private class StatementTranslator(private val prog: IntermediateProgram,
|
|||||||
range.step>1 -> {
|
range.step>1 -> {
|
||||||
prog.instr(opcodePushvar(varDt), callLabel = varname)
|
prog.instr(opcodePushvar(varDt), callLabel = varname)
|
||||||
prog.instr(opcodePush(varDt), Value(varDt, range.step))
|
prog.instr(opcodePush(varDt), Value(varDt, range.step))
|
||||||
prog.instr(opcodeSub(varDt))
|
prog.instr(opcodeAdd(varDt))
|
||||||
prog.instr(opcodePopvar(varDt), callLabel = varname)
|
prog.instr(opcodePopvar(varDt), callLabel = varname)
|
||||||
}
|
}
|
||||||
range.step<1 -> {
|
range.step<1 -> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7.2
|
// Generated from ../antlr/prog8.g4 by ANTLR 4.7.2
|
||||||
package prog8.parser;
|
package prog8.parser;
|
||||||
import org.antlr.v4.runtime.Lexer;
|
import org.antlr.v4.runtime.Lexer;
|
||||||
import org.antlr.v4.runtime.CharStream;
|
import org.antlr.v4.runtime.CharStream;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated from /home/irmen/Projects/prog8/compiler/antlr/prog8.g4 by ANTLR 4.7.2
|
// Generated from ../antlr/prog8.g4 by ANTLR 4.7.2
|
||||||
package prog8.parser;
|
package prog8.parser;
|
||||||
import org.antlr.v4.runtime.atn.*;
|
import org.antlr.v4.runtime.atn.*;
|
||||||
import org.antlr.v4.runtime.dfa.DFA;
|
import org.antlr.v4.runtime.dfa.DFA;
|
||||||
|
@ -27,10 +27,12 @@
|
|||||||
memory uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in
|
memory uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in
|
||||||
memory uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in
|
memory uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in
|
||||||
|
|
||||||
const uword Screen = $0400 ; default character screen matrix @todo matrix/array? needs to support array size > 255
|
; the default addresses for the character screen chars and colors
|
||||||
const uword Colors = $d800 ; character screen colors @todo matrix/array? needs to support array size > 255
|
const uword Screen = $0400 ; @todo matrix/array? needs to support array size > 255
|
||||||
|
const uword Colors = $d800 ; @todo matrix/array? needs to support array size > 255
|
||||||
|
|
||||||
memory ubyte SPRPTR0 = 2040 ; default sprite pointers (store address of sprite / 64)
|
; the default locations of the 8 sprite pointers (store address of sprite / 64)
|
||||||
|
memory ubyte SPRPTR0 = 2040
|
||||||
memory ubyte SPRPTR1 = 2041
|
memory ubyte SPRPTR1 = 2041
|
||||||
memory ubyte SPRPTR2 = 2042
|
memory ubyte SPRPTR2 = 2042
|
||||||
memory ubyte SPRPTR3 = 2043
|
memory ubyte SPRPTR3 = 2043
|
||||||
@ -132,6 +134,10 @@
|
|||||||
|
|
||||||
; ---- end of CIA registers ----
|
; ---- end of CIA registers ----
|
||||||
|
|
||||||
|
; @todo SID sound chip registers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---- C64 basic and kernal ROM float constants and functions ----
|
; ---- C64 basic and kernal ROM float constants and functions ----
|
||||||
|
|
||||||
; note: the fac1 and fac2 are working registers and take 6 bytes each,
|
; note: the fac1 and fac2 are working registers and take 6 bytes each,
|
||||||
|
Loading…
Reference in New Issue
Block a user