various fixes

This commit is contained in:
Irmen de Jong 2024-03-16 16:47:40 +01:00
parent 5b7801eea1
commit 5a0524ff4d
15 changed files with 63 additions and 1186 deletions

View File

@ -67,6 +67,7 @@ class PtProgram(
children.asSequence().filterIsInstance<PtBlock>()
fun entrypoint(): PtSub? =
// returns the main.start subroutine if it exists
allBlocks().firstOrNull { it.name == "main" || it.name=="p8b_main" }
?.children
?.firstOrNull { it is PtSub && (it.name == "start" || it.name=="main.start" || it.name=="p8s_start" || it.name=="p8b_main.p8s_start") } as PtSub?

View File

@ -98,7 +98,7 @@ romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; (via 810 ($32A)
romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files
romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock
romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) clobbers(A) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices
; ---- end of C64 compatible ROM kernal routines ----

View File

@ -37,8 +37,10 @@ sub bell() {
asmsub column(ubyte col @A) clobbers(A, X, Y) {
; ---- set the cursor on the given column (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tay
clc
jmp cbm.PLOT
@ -56,8 +58,10 @@ asmsub get_column() -> ubyte @Y {
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
; ---- set the cursor on the given row (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tax
clc
jmp cbm.PLOT

View File

@ -99,7 +99,7 @@ romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; (via 810 ($32A)
romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files
romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock
romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) clobbers(A) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices
asmsub STOP2() clobbers(X) -> bool @A {

View File

@ -43,8 +43,10 @@ sub bell() {
asmsub column(ubyte col @A) clobbers(A, X, Y) {
; ---- set the cursor on the given column (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tay
clc
jmp cbm.PLOT
@ -62,8 +64,10 @@ asmsub get_column() -> ubyte @Y {
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
; ---- set the cursor on the given row (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tax
clc
jmp cbm.PLOT

View File

@ -48,7 +48,7 @@ romsub $FFE4 = GETIN() clobbers(X,Y) -> bool @Pc, ubyte @ A ; (via 810 ($32A)
romsub $FFE7 = CLALL() clobbers(A,X) ; (via 812 ($32C)) close all files
romsub $FFEA = UDTIM() clobbers(A,X) ; update the software clock
romsub $FFED = SCREEN() -> ubyte @ X, ubyte @ Y ; read number of screen rows and columns
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF0 = PLOT(ubyte col @ Y, ubyte row @ X, bool dir @ Pc) clobbers(A) -> ubyte @ X, ubyte @ Y ; read/set position of cursor on screen. Use txt.plot for a 'safe' wrapper that preserves X.
romsub $FFF3 = IOBASE() -> uword @ XY ; read base address of I/O devices
; ---- utility

View File

@ -40,8 +40,10 @@ sub bell() {
asmsub column(ubyte col @A) clobbers(A, X, Y) {
; ---- set the cursor on the given column (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tay
clc
jmp cbm.PLOT
@ -58,8 +60,10 @@ asmsub get_column() -> ubyte @Y {
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
; ---- set the cursor on the given row (starting with 0) on the current line
%asm {{
pha
sec
jsr cbm.PLOT
pla
tax
clc
jmp cbm.PLOT

View File

@ -1,7 +1,7 @@
; Somewhat experimental Vera FX support.
; Docs:
; https://github.com/X16Community/x16-docs/blob/master/VERA%20FX%20Reference.md
; https://docs.google.com/document/d/1q34uWOiM3Be2pnaHRVgSdHySI-qsiQWPTo_gfE54PTg/edit
; https://github.com/X16Community/x16-docs/blob/master/X16%20Reference%20-%2010%20-%20VERA%20FX%20Reference.md
; https://docs.google.com/document/d/1q34uWOiM3Be2pnaHRVgSdHySI-qsiQWPTo_gfE54PTg
verafx {
%option no_symbol_prefixing, ignore_unused

View File

@ -34,49 +34,11 @@ sub bell() {
}
asmsub get_column() -> ubyte @Y {
%asm {{
sec
jmp cbm.PLOT
}}
}
asmsub row(ubyte rownum @A) clobbers(A, X, Y) {
; ---- set the cursor on the given row (starting with 0) on the current line
%asm {{
sec
jsr cbm.PLOT
tax
clc
jmp cbm.PLOT
}}
}
asmsub get_row() -> ubyte @X {
%asm {{
sec
jmp cbm.PLOT
}}
}
sub get_cursor(uword colptr, uword rowptr) {
%asm {{
sec
jsr cbm.PLOT
tya
ldy #$00
sta (colptr),y
txa
sta (rowptr),y
}}
}
asmsub fill_screen (ubyte character @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character. color is ignored on PET
%asm {{
jmp clear_screenchars
}}
}}
}

View File

@ -200,8 +200,7 @@ class TestCompilerOnExamplesVirtual: FunSpec({
"bouncegfx",
"bsieve",
"pixelshader",
"sincos",
"textelite"
"sincos"
)
onlyVirtual.forEach {

View File

@ -1,6 +1,10 @@
TODO
====
vm textelite: after 1 galaxy jump: galaxy map shows wrong planet name if you first print local area map. local map is wrong too (secnd time it's okay).
vm: textio.width and height should return the real console width and height.
...

View File

@ -1,40 +1,18 @@
%import math
%import textio
%zeropage basicsafe
%option no_sysinit
; $029f
main {
sub start() {
txt.print("crc16\n")
txt.print_uwhex(math.crc16($0800, 32768), true)
txt.nl()
cx16.r15 = 0
math.crc16_start()
for cx16.r9 in $0800 to $0800+32768-1 {
math.crc16_update(@(cx16.r9))
}
txt.print_uwhex(math.crc16_end(), true)
txt.nl()
txt.print("crc32\n")
cx16.r0 = cx16.r1 = 0
math.crc32($0800, 32768)
txt.print_uwhex(cx16.r15, true)
txt.print_uwhex(cx16.r14, false)
txt.nl()
cx16.r0 = cx16.r1 = 0
math.crc32_start()
for cx16.r9 in $0800 to $0800+32768-1 {
math.crc32_update(@(cx16.r9))
}
math.crc32_end()
txt.print_uwhex(cx16.r15, true)
txt.print_uwhex(cx16.r14, false)
txt.nl()
txt.print("hello, world!")
ubyte col = txt.get_column()
ubyte row = txt.get_row()
txt.row(10)
txt.print("row 10")
txt.column(2)
txt.print("col 2")
txt.plot(0, 18)
}
}

View File

@ -2,7 +2,6 @@
%import conv
%import diskio
%import string
%import test_stack
%option no_sysinit
%zeropage basicsafe
@ -30,8 +29,6 @@ main {
planet.display(false, 0)
repeat {
; test_stack.test()
str input = "????????"
txt.print("\nCash: ")
util.print_10s(ship.cash)
@ -72,7 +69,7 @@ main {
}
trader {
str Savegame = "commander.save"
str Savegame = "!commander.save"
str input = "??????????"
ubyte num_chars
@ -86,7 +83,7 @@ trader {
; 22 ubyte fuel
sub do_load() {
txt.print("\nLoading universe... (drive 8)")
txt.print("\nLoading universe...")
if diskio.load(Savegame, &savedata)!=0 {
txt.print("ok\n")
} else {
@ -114,7 +111,7 @@ trader {
savedata[22] = ship.fuel
sys.memcopy(ship.cargohold, &savedata + 2, len(ship.cargohold))
txt.print("\nSaving universe... (drive 8)")
txt.print("\nSaving universe...")
diskio.delete(Savegame)
if diskio.save(Savegame, &savedata, sizeof(savedata)) {
txt.print("ok\n")
@ -496,11 +493,16 @@ galaxy {
ubyte py = planet.y
str current_name = " " ; 8 max
ubyte pn = 0
uword scaling = 8
if local
scaling = 2
if txt.width() > 60
scaling /= 2
ubyte scaling_x = 8
ubyte scaling_y = 16
if local {
scaling_x = 2
scaling_y = 4
}
if txt.width() > 60 {
scaling_x /= 2
scaling_y /= 2
}
current_name = planet.name
init(number)
@ -524,15 +526,15 @@ galaxy {
ubyte distance = planet.distance(px, py)
if distance <= max_distance {
planet.name = make_current_planet_name()
planet.name[0] |= 32 ; uppercase first letter
planet.name[0] = string.upperchar(planet.name[0])
uword tx = planet.x
uword ty = planet.y
if local {
tx = tx + 24 - px
ty = ty + 24 - py
}
tx /= scaling
ty /= scaling*2
tx /= scaling_x
ty /= scaling_y
ubyte sx = lsb(tx)
ubyte sy = lsb(ty)
ubyte char = '*'
@ -558,7 +560,6 @@ galaxy {
else
txt.plot(0,36)
travel_to(number, current_planet)
sub print_planet_details(str name, ubyte screenx, ubyte screeny, ubyte d) {
@ -684,18 +685,6 @@ galaxy {
rol(xl)
return mkword(xh, xl)
}
sub debug_seed() {
txt.print("\ngalaxy #")
txt.print_ub(number)
txt.print("\ngalaxy seed0=")
txt.print_uwhex(galaxy.seed[0], true)
txt.print("\ngalaxy seed1=")
txt.print_uwhex(galaxy.seed[1], true)
txt.print("\ngalaxy seed2=")
txt.print_uwhex(galaxy.seed[2], true)
txt.nl()
}
}
planet {
@ -804,7 +793,7 @@ planet {
}
}
randname[nx] = 0
randname[0] |= 32 ; uppercase first letter
randname[0] = string.upperchar(randname[0])
return randname
}
@ -876,12 +865,12 @@ planet {
source_ptr = source_stack[stack_ptr]
} else {
if c == $b0 {
@(result_ptr) = name[0] | 32
@(result_ptr) = string.upperchar(name[0])
result_ptr++
concat_string(&name + 1)
}
else if c == $b1 {
@(result_ptr) = name[0] | 32
@(result_ptr) = string.upperchar(name[0])
result_ptr++
ubyte ni
for ni in 1 to len(name) {
@ -995,33 +984,13 @@ planet {
}
sub print_name_uppercase() {
ubyte c
for c in name
txt.chrout(c | 32)
for cx16.r0L in name
txt.chrout(string.upperchar(cx16.r0L))
}
asmsub getword(ubyte list @A, ubyte wordidx @Y) -> uword @AY {
%asm {{
sty P8ZP_SCRATCH_REG
sec
sbc #$81
asl a
tay
lda p8v_wordlists,y
sta P8ZP_SCRATCH_W1
lda p8v_wordlists+1,y
sta P8ZP_SCRATCH_W1+1
lda P8ZP_SCRATCH_REG
asl a
tay
lda (P8ZP_SCRATCH_W1),y
pha
iny
lda (P8ZP_SCRATCH_W1),y
tay
pla
rts
}}
sub getword(ubyte listnum, ubyte wordidx) -> uword {
uword list = wordlists[listnum-$81]
return peekw(list + wordidx*2)
}
}
@ -1033,9 +1002,7 @@ util {
if pc == 0
return true
; to lowercase for case insensitive compare:
pc &= 127
sc &= 127
if pc != sc
if string.lowerchar(pc)!=string.lowerchar(sc)
return false
prefixptr++
stringptr++
@ -1049,37 +1016,9 @@ util {
txt.print(s)
}
asmsub print_10s(uword value @AY) clobbers(A, X, Y) {
%asm {{
jsr conv.uword2decimal
lda conv.uword2decimal.decTenThousands
ldy #0 ; have we started printing?
cmp #'0'
beq +
jsr cbm.CHROUT
iny
+ lda conv.uword2decimal.decThousands
cmp #'0'
bne +
cpy #0
beq ++
+ jsr cbm.CHROUT
iny
+ lda conv.uword2decimal.decHundreds
cmp #'0'
bne +
cpy #0
beq ++
+ jsr cbm.CHROUT
iny
+ lda conv.uword2decimal.decTens
jsr cbm.CHROUT
lda #'.'
jsr cbm.CHROUT
lda conv.uword2decimal.decOnes
jsr cbm.CHROUT
rts
}}
sub print_10s(uword value) {
txt.print_uw(value/10)
txt.chrout('.')
txt.print_uw(value % 10)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -664,7 +664,8 @@ object SysCalls {
}
}
Syscall.SAVE -> {
val (raw, filenamePtr, startA, sizeA) = getArgValues(callspec.arguments, vm)
val (rawA, filenamePtr, startA, sizeA) = getArgValues(callspec.arguments, vm)
val raw = (rawA as UByte).toInt()
val size = (sizeA as UShort).toInt()
val startPtr = (startA as UShort).toInt()
val data: ByteArray