mirror of
https://github.com/irmen/prog8.git
synced 2024-09-08 10:55:08 +00:00
adapted p8 code to restricted array indexing
This commit is contained in:
parent
7626c9fff7
commit
157484d94b
@ -221,7 +221,7 @@ private fun writeAssembly(programAst: Program, errors: ErrorReporter, outputDir:
|
|||||||
programAst.processAstBeforeAsmGeneration(errors)
|
programAst.processAstBeforeAsmGeneration(errors)
|
||||||
errors.handle()
|
errors.handle()
|
||||||
|
|
||||||
printAst(programAst) // TODO
|
// printAst(programAst)
|
||||||
|
|
||||||
CompilationTarget.instance.machine.initializeZeropage(compilerOptions)
|
CompilationTarget.instance.machine.initializeZeropage(compilerOptions)
|
||||||
val assembly = CompilationTarget.instance.asmGenerator(
|
val assembly = CompilationTarget.instance.asmGenerator(
|
||||||
|
@ -166,7 +166,8 @@ main {
|
|||||||
else
|
else
|
||||||
c64.SPRPTR[i] = $2000/64 ; small ball
|
c64.SPRPTR[i] = $2000/64 ; small ball
|
||||||
|
|
||||||
c64.SPCOL[i] = spritecolors[(zc>>13) as byte + 4] ; further away=darker color
|
ubyte sci = (zc>>13) as ubyte + 4 ; TODO is index for array
|
||||||
|
c64.SPCOL[i] = spritecolors[sci] ; further away=darker color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ main {
|
|||||||
|
|
||||||
|
|
||||||
while multiple < len(sieve) {
|
while multiple < len(sieve) {
|
||||||
sieve[lsb(multiple)] = true
|
ubyte si = lsb(multiple) ; TODO is index for array
|
||||||
|
sieve[si] = true
|
||||||
multiple += candidate_prime
|
multiple += candidate_prime
|
||||||
}
|
}
|
||||||
return candidate_prime
|
return candidate_prime
|
||||||
|
@ -41,8 +41,10 @@ main {
|
|||||||
ubyte @zp i
|
ubyte @zp i
|
||||||
for i in 0 to 7 {
|
for i in 0 to 7 {
|
||||||
c64.SPRPTR[i] = $0a00 / 64
|
c64.SPRPTR[i] = $0a00 / 64
|
||||||
c64.SPXY[i*2] = 50+25*i
|
ubyte twoi = i*2 ; TODO is index for array
|
||||||
c64.SPXY[i*2+1] = rnd()
|
c64.SPXY[twoi] = 50+25*i
|
||||||
|
twoi++ ; TODO is index for array
|
||||||
|
c64.SPXY[twoi] = rnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
c64.SPENA = 255 ; enable all sprites
|
c64.SPENA = 255 ; enable all sprites
|
||||||
@ -59,7 +61,8 @@ irq {
|
|||||||
; float up & wobble horizontally
|
; float up & wobble horizontally
|
||||||
ubyte @zp i
|
ubyte @zp i
|
||||||
for i in 0 to 14 step 2 {
|
for i in 0 to 14 step 2 {
|
||||||
c64.SPXY[i+1]--
|
ubyte ipp=i+1 ; TODO is index for array
|
||||||
|
c64.SPXY[ipp]--
|
||||||
ubyte @zp r = rnd()
|
ubyte @zp r = rnd()
|
||||||
if r>200
|
if r>200
|
||||||
c64.SPXY[i]++
|
c64.SPXY[i]++
|
||||||
|
@ -219,7 +219,8 @@ waitkey:
|
|||||||
blocklogic.collapse(linepos)
|
blocklogic.collapse(linepos)
|
||||||
lines += num_lines
|
lines += num_lines
|
||||||
uword[] scores = [10, 25, 50, 100] ; can never clear more than 4 lines
|
uword[] scores = [10, 25, 50, 100] ; can never clear more than 4 lines
|
||||||
score += scores[num_lines-1]
|
ubyte scorei = num_lines-1 ; TODO is index for array
|
||||||
|
score += scores[scorei]
|
||||||
speedlevel = 1+lsb(lines/10)
|
speedlevel = 1+lsb(lines/10)
|
||||||
drawScore()
|
drawScore()
|
||||||
}
|
}
|
||||||
|
@ -1,81 +1,12 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
|
%import floats
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
%option force_output
|
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
str hex1 = "aap2"
|
|
||||||
str hex2 = "aap1je"
|
|
||||||
str hex3 = "aap1JE"
|
|
||||||
str hex4 = "aap3333"
|
|
||||||
|
|
||||||
; byte result
|
|
||||||
; result = strcmp(hex1, hex1)
|
|
||||||
; txt.print_b(result)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
; result = strcmp(hex1, hex1)
|
|
||||||
; txt.print_b(result)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
; result = strcmp(hex1, hex2)
|
|
||||||
; txt.print_b(result)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
; result = strcmp(hex1, hex3)
|
|
||||||
; txt.print_b(result)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
; result = strcmp(hex1, hex4)
|
|
||||||
; txt.print_b(result)
|
|
||||||
; txt.chrout('\n')
|
|
||||||
; txt.chrout('\n')
|
|
||||||
|
|
||||||
if hex1==hex2
|
|
||||||
txt.print("1 fail ==\n")
|
|
||||||
else
|
|
||||||
txt.print("1 ok not ==\n")
|
|
||||||
endlab1:
|
|
||||||
if hex1!=hex2
|
|
||||||
txt.print("2 ok !==\n")
|
|
||||||
else
|
|
||||||
txt.print("2 fail not !=\n")
|
|
||||||
endlab2:
|
|
||||||
if hex1>=hex2
|
|
||||||
txt.print("3 ok >=\n")
|
|
||||||
else
|
|
||||||
txt.print("3 fail not >=\n")
|
|
||||||
endlab3:
|
|
||||||
if hex1<=hex2
|
|
||||||
txt.print("4 fail <=\n")
|
|
||||||
else
|
|
||||||
txt.print("4 ok not <=\n")
|
|
||||||
endlab4:
|
|
||||||
if hex1>hex2
|
|
||||||
txt.print("5 ok >\n")
|
|
||||||
else
|
|
||||||
txt.print("5 fail not >\n")
|
|
||||||
endlab5:
|
|
||||||
if hex1<hex2
|
|
||||||
txt.print("5 fail <\n")
|
|
||||||
else
|
|
||||||
txt.print("6 ok not <\n")
|
|
||||||
|
|
||||||
endlab6:
|
|
||||||
txt.chrout('\n')
|
|
||||||
|
|
||||||
txt.print_ub(hex1==hex2)
|
|
||||||
txt.print(" 0?\n")
|
|
||||||
txt.print_ub(hex1!=hex2)
|
|
||||||
txt.print(" 1?\n")
|
|
||||||
txt.print_ub(hex1>hex2)
|
|
||||||
txt.print(" 1?\n")
|
|
||||||
txt.print_ub(hex1<hex2)
|
|
||||||
txt.print(" 0?\n")
|
|
||||||
txt.print_ub(hex1>=hex2)
|
|
||||||
txt.print(" 1?\n")
|
|
||||||
txt.print_ub(hex1<=hex2)
|
|
||||||
txt.print(" 0?\n")
|
|
||||||
|
|
||||||
testX()
|
testX()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,20 +83,20 @@ main {
|
|||||||
uw=muwarray[bb]
|
uw=muwarray[bb]
|
||||||
fl=mflarray[bb]
|
fl=mflarray[bb]
|
||||||
|
|
||||||
A=s1[bb*3]
|
; A=s1[bb*3]
|
||||||
ub=s1[bb*3]
|
; ub=s1[bb*3]
|
||||||
bb=barray[bb*3]
|
; bb=barray[bb*3]
|
||||||
ub=ubarray[bb*3]
|
; ub=ubarray[bb*3]
|
||||||
ww=warray[bb*3]
|
; ww=warray[bb*3]
|
||||||
uw=uwarray[bb*3]
|
; uw=uwarray[bb*3]
|
||||||
fl=flarray[bb*3]
|
; fl=flarray[bb*3]
|
||||||
A=ms1[bb*3]
|
; A=ms1[bb*3]
|
||||||
ub=ms1[bb*3]
|
; ub=ms1[bb*3]
|
||||||
bb=mbarray[bb*3]
|
; bb=mbarray[bb*3]
|
||||||
ub=mubarray[bb*3]
|
; ub=mubarray[bb*3]
|
||||||
ww=mwarray[bb*3]
|
; ww=mwarray[bb*3]
|
||||||
uw=muwarray[bb*3]
|
; uw=muwarray[bb*3]
|
||||||
fl=mflarray[bb*3]
|
; fl=mflarray[bb*3]
|
||||||
|
|
||||||
; write array
|
; write array
|
||||||
barray[2]++
|
barray[2]++
|
||||||
@ -132,11 +132,11 @@ main {
|
|||||||
uwarray[bb] = uw
|
uwarray[bb] = uw
|
||||||
flarray[bb] = fl
|
flarray[bb] = fl
|
||||||
|
|
||||||
s1[bb*3] = ub
|
; s1[bb*3] = ub
|
||||||
barray[bb*3] = bb
|
; barray[bb*3] = bb
|
||||||
ubarray[bb*3] = ub
|
; ubarray[bb*3] = ub
|
||||||
warray[bb*3] = ww
|
; warray[bb*3] = ww
|
||||||
uwarray[bb*3] = uw
|
; uwarray[bb*3] = uw
|
||||||
flarray[bb*3] = fl
|
; flarray[bb*3] = fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
|
; TODO error check on load, now wipes cash and fuel etc when load fails
|
||||||
; TODO finalize and test save/load game function
|
; TODO finalize and test save/load game function
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -360,7 +360,8 @@ market {
|
|||||||
util.print_10s(current_price[ci])
|
util.print_10s(current_price[ci])
|
||||||
txt.print(" ")
|
txt.print(" ")
|
||||||
txt.print_ub(current_quantity[ci])
|
txt.print_ub(current_quantity[ci])
|
||||||
txt.print(unitnames[units[ci]])
|
ubyte ui = units[ci] ; TODO is index for array
|
||||||
|
txt.print(unitnames[ui])
|
||||||
txt.print(" ")
|
txt.print(" ")
|
||||||
txt.print_ub(ship.cargohold[ci])
|
txt.print_ub(ship.cargohold[ci])
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
@ -505,28 +506,33 @@ galaxy {
|
|||||||
sub make_current_planet_name() -> str {
|
sub make_current_planet_name() -> str {
|
||||||
ubyte ni = 0
|
ubyte ni = 0
|
||||||
str name = " " ; max 8
|
str name = " " ; max 8
|
||||||
|
ubyte pn_pair1_p1 = pn_pair1+1 ; TODO is index for array
|
||||||
|
ubyte pn_pair2_p1 = pn_pair2+1 ; TODO is index for array
|
||||||
|
ubyte pn_pair3_p1 = pn_pair3+1 ; TODO is index for array
|
||||||
|
ubyte pn_pair4_p1 = pn_pair4+1 ; TODO is index for array
|
||||||
|
|
||||||
if pn_pairs[pn_pair1] != '.' {
|
if pn_pairs[pn_pair1] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair1]
|
name[ni] = pn_pairs[pn_pair1]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair1+1] != '.' {
|
if pn_pairs[pn_pair1_p1] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair1+1]
|
name[ni] = pn_pairs[pn_pair1_p1]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair2] != '.' {
|
if pn_pairs[pn_pair2] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair2]
|
name[ni] = pn_pairs[pn_pair2]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair2+1] != '.' {
|
if pn_pairs[pn_pair2_p1] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair2+1]
|
name[ni] = pn_pairs[pn_pair2_p1]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair3] != '.' {
|
if pn_pairs[pn_pair3] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair3]
|
name[ni] = pn_pairs[pn_pair3]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair3+1] != '.' {
|
if pn_pairs[pn_pair3_p1] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair3+1]
|
name[ni] = pn_pairs[pn_pair3_p1]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,8 +541,8 @@ galaxy {
|
|||||||
name[ni] = pn_pairs[pn_pair4]
|
name[ni] = pn_pairs[pn_pair4]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
if pn_pairs[pn_pair4+1] != '.' {
|
if pn_pairs[pn_pair4_p1] != '.' {
|
||||||
name[ni] = pn_pairs[pn_pair4+1]
|
name[ni] = pn_pairs[pn_pair4_p1]
|
||||||
ni++
|
ni++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -704,8 +710,9 @@ planet {
|
|||||||
name[nx] = pairs0[x]
|
name[nx] = pairs0[x]
|
||||||
nx++
|
nx++
|
||||||
}
|
}
|
||||||
if pairs0[x+1] != '.' {
|
x++ ; TODO is index for array
|
||||||
name[nx] = pairs0[x+1]
|
if pairs0[x] != '.' {
|
||||||
|
name[nx] = pairs0[x]
|
||||||
nx++
|
nx++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
%import graphics
|
%import graphics
|
||||||
%zeropage floatsafe
|
%zeropage floatsafe
|
||||||
|
|
||||||
|
; TODO Fix broken line output
|
||||||
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
Loading…
Reference in New Issue
Block a user