mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 16:29:21 +00:00
fix monogfx issue
This commit is contained in:
parent
a5a918df84
commit
51d708bbdd
@ -7,8 +7,6 @@
|
|||||||
; NOTE: a lot of the code here is similar or the same to that in gfx2
|
; NOTE: a lot of the code here is similar or the same to that in gfx2
|
||||||
; NOTE: For sake of speed, NO BOUNDS CHECKING is performed in most routines!
|
; NOTE: For sake of speed, NO BOUNDS CHECKING is performed in most routines!
|
||||||
; You'll have to make sure yourself that you're not writing outside of bitmap boundaries!
|
; You'll have to make sure yourself that you're not writing outside of bitmap boundaries!
|
||||||
;
|
|
||||||
; TODO: implement invert mode for horizontal lines (will fix disc and fillrect as well)
|
|
||||||
|
|
||||||
monogfx {
|
monogfx {
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ monogfx {
|
|||||||
dy = stack_dy[cx16.r12L]
|
dy = stack_dy[cx16.r12L]
|
||||||
yy+=dy
|
yy+=dy
|
||||||
}
|
}
|
||||||
cx16.r11L = pget(xx as uword, yy as uword) ; old_color
|
cx16.r11L = pget(xx as uword, yy as uword) as ubyte ; old_color
|
||||||
if cx16.r11L == cx16.r10L
|
if cx16.r11L == cx16.r10L
|
||||||
return
|
return
|
||||||
if xx<0 or xx>width-1 or yy<0 or yy>height-1
|
if xx<0 or xx>width-1 or yy<0 or yy>height-1
|
||||||
|
@ -56,8 +56,6 @@ class CompilerArguments(val filepath: Path,
|
|||||||
|
|
||||||
|
|
||||||
fun compileProgram(args: CompilerArguments): CompilationResult? {
|
fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||||
lateinit var program: Program
|
|
||||||
lateinit var importedFiles: List<Path>
|
|
||||||
|
|
||||||
val compTarget =
|
val compTarget =
|
||||||
when(args.compilationTarget) {
|
when(args.compilationTarget) {
|
||||||
@ -72,10 +70,12 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
|||||||
|
|
||||||
var compilationOptions: CompilationOptions
|
var compilationOptions: CompilationOptions
|
||||||
var ast: PtProgram? = null
|
var ast: PtProgram? = null
|
||||||
|
var resultingProgram: Program? = null
|
||||||
|
var importedFiles: List<Path> = emptyList()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val totalTime = measureTimeMillis {
|
val totalTime = measureTimeMillis {
|
||||||
val (programresult, options, imported) = parseMainModule(args.filepath, args.errors, compTarget, args.sourceDirs)
|
val (program, options, imported) = parseMainModule(args.filepath, args.errors, compTarget, args.sourceDirs)
|
||||||
compilationOptions = options
|
compilationOptions = options
|
||||||
|
|
||||||
with(compilationOptions) {
|
with(compilationOptions) {
|
||||||
@ -96,7 +96,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
|||||||
symbolDefs = args.symbolDefs
|
symbolDefs = args.symbolDefs
|
||||||
strictBool = args.strictBool
|
strictBool = args.strictBool
|
||||||
}
|
}
|
||||||
program = programresult
|
resultingProgram = program
|
||||||
importedFiles = imported
|
importedFiles = imported
|
||||||
|
|
||||||
processAst(program, args.errors, compilationOptions)
|
processAst(program, args.errors, compilationOptions)
|
||||||
@ -164,16 +164,16 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
|||||||
System.err.flush()
|
System.err.flush()
|
||||||
val seconds = totalTime/1000.0
|
val seconds = totalTime/1000.0
|
||||||
println("\nTotal compilation+assemble time: ${round(seconds*100.0)/100.0} sec.")
|
println("\nTotal compilation+assemble time: ${round(seconds*100.0)/100.0} sec.")
|
||||||
return CompilationResult(program, ast, compilationOptions, importedFiles)
|
return CompilationResult(resultingProgram!!, ast, compilationOptions, importedFiles)
|
||||||
} catch (px: ParseError) {
|
} catch (px: ParseError) {
|
||||||
System.out.flush()
|
System.out.flush()
|
||||||
System.err.print("\n\u001b[91m") // bright red
|
System.err.print("\n\u001b[91m") // bright red
|
||||||
System.err.println("${px.position.toClickableStr()} parse error: ${px.message}".trim())
|
System.err.println("${px.position.toClickableStr()} parse error: ${px.message}".trim())
|
||||||
System.err.print("\u001b[0m") // reset
|
System.err.print("\u001b[0m") // reset
|
||||||
} catch (ac: ErrorsReportedException) {
|
} catch (ac: ErrorsReportedException) {
|
||||||
if(args.printAst1) {
|
if(args.printAst1 && resultingProgram!=null) {
|
||||||
println("\n*********** COMPILER AST *************")
|
println("\n*********** COMPILER AST *************")
|
||||||
printProgram(program)
|
printProgram(resultingProgram!!)
|
||||||
println("*********** COMPILER AST END *************\n")
|
println("*********** COMPILER AST END *************\n")
|
||||||
}
|
}
|
||||||
if (args.printAst2) {
|
if (args.printAst2) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
fix containment check is currently not supported inside complex expressions
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
146
examples/test.p8
146
examples/test.p8
@ -1,127 +1,35 @@
|
|||||||
%import textio
|
%import math
|
||||||
%option no_sysinit
|
%import monogfx
|
||||||
%zeropage basicsafe
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword @shared ref = $2000
|
monogfx.lores()
|
||||||
ref[5]=10
|
monogfx.drawmode(monogfx.MODE_INVERT)
|
||||||
txt.print_ub(ref[5])
|
|
||||||
txt.spc()
|
uword x1, x2
|
||||||
ref[5]--
|
uword y1, y2
|
||||||
txt.print_ub(ref[5])
|
|
||||||
txt.spc()
|
repeat 200 {
|
||||||
ref[5]++
|
x1 = math.rnd()
|
||||||
txt.print_ub(ref[5])
|
y1 = math.rnd() % 240
|
||||||
txt.nl()
|
x2 = math.rnd()
|
||||||
ref[5]-=2
|
y2 = math.rnd() % 240
|
||||||
txt.print_ub(ref[5])
|
monogfx.line(x1, y1, x2, y2, true)
|
||||||
txt.spc()
|
}
|
||||||
ref[5]+=2
|
|
||||||
txt.print_ub(ref[5])
|
repeat 5 {
|
||||||
txt.nl()
|
for cx16.r9L in 0 to 200 {
|
||||||
ref[5]-=3
|
monogfx.vertical_line(cx16.r9L, 10, 200, true)
|
||||||
txt.print_ub(ref[5])
|
}
|
||||||
txt.spc()
|
}
|
||||||
ref[5]+=3
|
|
||||||
txt.print_ub(ref[5])
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
|
|
||||||
ubyte[] array = [1,2,3,4,5,10]
|
monogfx.disc(160, 120, 100, true)
|
||||||
array[5]=10
|
monogfx.fillrect(20, 100, 280, 50, true)
|
||||||
txt.print_ub(array[5])
|
monogfx.drawmode(monogfx.MODE_STIPPLE)
|
||||||
txt.spc()
|
monogfx.fillrect(80, 10, 50, 220, true)
|
||||||
array[5]--
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.spc()
|
|
||||||
array[5]++
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.nl()
|
|
||||||
array[5]-=2
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.spc()
|
|
||||||
array[5]+=2
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.nl()
|
|
||||||
array[5]-=3
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.spc()
|
|
||||||
array[5]+=3
|
|
||||||
txt.print_ub(array[5])
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
|
|
||||||
; cx16.r0L = 5
|
|
||||||
; ref[cx16.r0L]=10
|
|
||||||
; txt.print_ub(ref[cx16.r0L])
|
|
||||||
; txt.spc()
|
|
||||||
; ref[cx16.r0L]--
|
|
||||||
; txt.print_ub(ref[cx16.r0L])
|
|
||||||
; txt.spc()
|
|
||||||
; ref[cx16.r0L]++
|
|
||||||
; txt.print_ub(ref[cx16.r0L])
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; uword @shared uw = 1000
|
|
||||||
; word @shared sw = -1000
|
|
||||||
;
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.spc()
|
|
||||||
; uw++
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.spc()
|
|
||||||
; uw--
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.nl()
|
|
||||||
; uw = $00ff
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.spc()
|
|
||||||
; uw++
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.spc()
|
|
||||||
; uw--
|
|
||||||
; txt.print_uw(uw)
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw++
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw--
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.nl()
|
|
||||||
; sw = $00ff
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw++
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw--
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.nl()
|
|
||||||
; sw = -257
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw++
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.spc()
|
|
||||||
; sw--
|
|
||||||
; txt.print_w(sw)
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
/*
|
|
||||||
seekerRef[SKR_X]-- this code looks very wrong with the pha/pla stuff
|
|
||||||
bulletRef[BD_Y]--/++
|
|
||||||
enemyRef[EN_MOVE_CNT]--/++
|
|
||||||
|
|
||||||
signed word--/++
|
|
||||||
unsigned word--/++
|
|
||||||
|
|
||||||
attackRef+=FIELD_COUNT
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
repeat {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user