mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +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: 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!
|
||||
;
|
||||
; TODO: implement invert mode for horizontal lines (will fix disc and fillrect as well)
|
||||
|
||||
monogfx {
|
||||
|
||||
|
@ -409,7 +409,7 @@ monogfx {
|
||||
dy = stack_dy[cx16.r12L]
|
||||
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
|
||||
return
|
||||
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? {
|
||||
lateinit var program: Program
|
||||
lateinit var importedFiles: List<Path>
|
||||
|
||||
val compTarget =
|
||||
when(args.compilationTarget) {
|
||||
@ -72,10 +70,12 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
|
||||
var compilationOptions: CompilationOptions
|
||||
var ast: PtProgram? = null
|
||||
var resultingProgram: Program? = null
|
||||
var importedFiles: List<Path> = emptyList()
|
||||
|
||||
try {
|
||||
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
|
||||
|
||||
with(compilationOptions) {
|
||||
@ -96,7 +96,7 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
symbolDefs = args.symbolDefs
|
||||
strictBool = args.strictBool
|
||||
}
|
||||
program = programresult
|
||||
resultingProgram = program
|
||||
importedFiles = imported
|
||||
|
||||
processAst(program, args.errors, compilationOptions)
|
||||
@ -164,16 +164,16 @@ fun compileProgram(args: CompilerArguments): CompilationResult? {
|
||||
System.err.flush()
|
||||
val seconds = totalTime/1000.0
|
||||
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) {
|
||||
System.out.flush()
|
||||
System.err.print("\n\u001b[91m") // bright red
|
||||
System.err.println("${px.position.toClickableStr()} parse error: ${px.message}".trim())
|
||||
System.err.print("\u001b[0m") // reset
|
||||
} catch (ac: ErrorsReportedException) {
|
||||
if(args.printAst1) {
|
||||
if(args.printAst1 && resultingProgram!=null) {
|
||||
println("\n*********** COMPILER AST *************")
|
||||
printProgram(program)
|
||||
printProgram(resultingProgram!!)
|
||||
println("*********** COMPILER AST END *************\n")
|
||||
}
|
||||
if (args.printAst2) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
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
|
||||
%option no_sysinit
|
||||
%zeropage basicsafe
|
||||
%import math
|
||||
%import monogfx
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword @shared ref = $2000
|
||||
ref[5]=10
|
||||
txt.print_ub(ref[5])
|
||||
txt.spc()
|
||||
ref[5]--
|
||||
txt.print_ub(ref[5])
|
||||
txt.spc()
|
||||
ref[5]++
|
||||
txt.print_ub(ref[5])
|
||||
txt.nl()
|
||||
ref[5]-=2
|
||||
txt.print_ub(ref[5])
|
||||
txt.spc()
|
||||
ref[5]+=2
|
||||
txt.print_ub(ref[5])
|
||||
txt.nl()
|
||||
ref[5]-=3
|
||||
txt.print_ub(ref[5])
|
||||
txt.spc()
|
||||
ref[5]+=3
|
||||
txt.print_ub(ref[5])
|
||||
txt.nl()
|
||||
monogfx.lores()
|
||||
monogfx.drawmode(monogfx.MODE_INVERT)
|
||||
|
||||
uword x1, x2
|
||||
uword y1, y2
|
||||
|
||||
repeat 200 {
|
||||
x1 = math.rnd()
|
||||
y1 = math.rnd() % 240
|
||||
x2 = math.rnd()
|
||||
y2 = math.rnd() % 240
|
||||
monogfx.line(x1, y1, x2, y2, true)
|
||||
}
|
||||
|
||||
repeat 5 {
|
||||
for cx16.r9L in 0 to 200 {
|
||||
monogfx.vertical_line(cx16.r9L, 10, 200, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ubyte[] array = [1,2,3,4,5,10]
|
||||
array[5]=10
|
||||
txt.print_ub(array[5])
|
||||
txt.spc()
|
||||
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
|
||||
|
||||
*/
|
||||
monogfx.disc(160, 120, 100, true)
|
||||
monogfx.fillrect(20, 100, 280, 50, true)
|
||||
monogfx.drawmode(monogfx.MODE_STIPPLE)
|
||||
monogfx.fillrect(80, 10, 50, 220, true)
|
||||
|
||||
repeat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user