mirror of
https://github.com/irmen/prog8.git
synced 2025-02-22 16:29:05 +00:00
added txt.petscii2scr() and txt.petscii2scr_str()
This commit is contained in:
parent
73ec8c31ad
commit
d33aed4ed5
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import conv
|
%import conv
|
||||||
|
%import shared_textio_functions
|
||||||
|
|
||||||
txt {
|
txt {
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import conv
|
%import conv
|
||||||
|
%import shared_textio_functions
|
||||||
|
|
||||||
|
|
||||||
txt {
|
txt {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
; Prog8 definitions for floating point handling on the Commodore-64
|
; Prog8 definitions for floating point handling on the Commodore-64
|
||||||
|
|
||||||
%option enable_floats, no_symbol_prefixing, ignore_unused
|
%option enable_floats, no_symbol_prefixing, ignore_unused
|
||||||
%import floats_functions
|
%import shared_floats_functions
|
||||||
|
|
||||||
floats {
|
floats {
|
||||||
; ---- this block contains C-64 floating point related functions ----
|
; ---- this block contains C-64 floating point related functions ----
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import conv
|
%import conv
|
||||||
|
%import shared_textio_functions
|
||||||
|
|
||||||
txt {
|
txt {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
; Prog8 definitions for floating point handling on the CommanderX16
|
; Prog8 definitions for floating point handling on the CommanderX16
|
||||||
|
|
||||||
%option enable_floats, no_symbol_prefixing, ignore_unused
|
%option enable_floats, no_symbol_prefixing, ignore_unused
|
||||||
%import floats_functions
|
%import shared_floats_functions
|
||||||
|
|
||||||
floats {
|
floats {
|
||||||
; ---- this block contains C-64 compatible floating point related functions ----
|
; ---- this block contains C-64 compatible floating point related functions ----
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import conv
|
%import conv
|
||||||
|
%import shared_textio_functions
|
||||||
|
|
||||||
txt {
|
txt {
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
%import syslib
|
%import syslib
|
||||||
%import conv
|
%import conv
|
||||||
|
%import shared_textio_functions
|
||||||
|
|
||||||
txt {
|
txt {
|
||||||
%option no_symbol_prefixing, ignore_unused
|
%option no_symbol_prefixing, ignore_unused
|
||||||
|
39
compiler/res/prog8lib/shared_textio_functions.p8
Normal file
39
compiler/res/prog8lib/shared_textio_functions.p8
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
txt {
|
||||||
|
; the textio functions shared across compiler targets
|
||||||
|
%option merge, no_symbol_prefixing, ignore_unused
|
||||||
|
|
||||||
|
asmsub petscii2scr(ubyte petscii_char @A) -> ubyte @A {
|
||||||
|
; -- convert petscii character to screencode
|
||||||
|
%asm {{
|
||||||
|
sta P8ZP_SCRATCH_REG
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
|
tax
|
||||||
|
lda _offsets,x
|
||||||
|
eor P8ZP_SCRATCH_REG
|
||||||
|
rts
|
||||||
|
_offsets .byte 128, 0, 64, 32, 64, 192, 128, 128
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub petscii2scr_str(str petscii_string @AY) {
|
||||||
|
; -- convert petscii string to screencodes string
|
||||||
|
%asm {{
|
||||||
|
sta P8ZP_SCRATCH_W1
|
||||||
|
sty P8ZP_SCRATCH_W1+1
|
||||||
|
ldy #0
|
||||||
|
- lda (P8ZP_SCRATCH_W1),y
|
||||||
|
beq +
|
||||||
|
jsr petscii2scr
|
||||||
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
|
iny
|
||||||
|
bne -
|
||||||
|
+ rts
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -145,4 +145,19 @@ sub setchr (ubyte col, ubyte row, ubyte char) {
|
|||||||
txt.chrout(char)
|
txt.chrout(char)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub petscii2scr(ubyte petscii_char) -> ubyte {
|
||||||
|
; -- convert petscii character to screencode
|
||||||
|
byte[8] offsets = [128, 0, 64, 32, 64, 192, 128, 128]
|
||||||
|
return petscii_char ^ offsets[petscii_char>>5]
|
||||||
|
}
|
||||||
|
|
||||||
|
sub petscii2scr_str(str petscii_string) {
|
||||||
|
; -- convert petscii string to screencodes string
|
||||||
|
cx16.r0 = petscii_string
|
||||||
|
while @(cx16.r0)!=0 {
|
||||||
|
@(cx16.r0) = petscii2scr(@(cx16.r0))
|
||||||
|
cx16.r0++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,9 @@ main {
|
|||||||
"textio",
|
"textio",
|
||||||
"syslib",
|
"syslib",
|
||||||
"conv",
|
"conv",
|
||||||
|
"shared_textio_functions",
|
||||||
"floats",
|
"floats",
|
||||||
"floats_functions",
|
"shared_floats_functions",
|
||||||
"math",
|
"math",
|
||||||
"prog8_lib"
|
"prog8_lib"
|
||||||
)
|
)
|
||||||
@ -100,7 +101,7 @@ main {
|
|||||||
listOf(
|
listOf(
|
||||||
internedStringsModuleName,
|
internedStringsModuleName,
|
||||||
filenameBase,
|
filenameBase,
|
||||||
"textio", "syslib", "conv", "floats", "floats_functions", "math", "prog8_lib"
|
"textio", "syslib", "conv", "shared_textio_functions", "floats", "shared_floats_functions", "math", "prog8_lib"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
options.floats shouldBe true
|
options.floats shouldBe true
|
||||||
|
@ -177,6 +177,7 @@ dealing with text-based input and output (to the screen). Such as
|
|||||||
- filling or clearing the screen and colors
|
- filling or clearing the screen and colors
|
||||||
- scrolling the text on the screen
|
- scrolling the text on the screen
|
||||||
- placing individual characters on the screen
|
- placing individual characters on the screen
|
||||||
|
- convert petscii to screencode characters
|
||||||
|
|
||||||
All routines work with Screencode character encoding, except `print`, `chrout` and `input_chars`,
|
All routines work with Screencode character encoding, except `print`, `chrout` and `input_chars`,
|
||||||
these work with PETSCII encoding instead.
|
these work with PETSCII encoding instead.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
&pointervar[x] isn't correct?? (at least in IR)
|
&pointervar[x] isn't the correct value
|
||||||
|
&pointervar[x] AST doesn't print correctly
|
||||||
|
@(s) where s is a str parameter, doesn't work
|
||||||
|
|
||||||
(after merge in boolean): move all "OperatorXinplace" from expressionGen to AssignmentGen, see if we can get rid of the Result return type.
|
(after merge in boolean): move all "OperatorXinplace" from expressionGen to AssignmentGen, see if we can get rid of the Result return type.
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ Future Things and Ideas
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
Compiler:
|
Compiler:
|
||||||
|
|
||||||
|
- can we support singed % (remainder) somehow?
|
||||||
- instead of copy-pasting inline asmsubs, make them into a 64tass macro and use that instead.
|
- instead of copy-pasting inline asmsubs, make them into a 64tass macro and use that instead.
|
||||||
that will allow them to be reused from custom user written assembly code as well.
|
that will allow them to be reused from custom user written assembly code as well.
|
||||||
- Multidimensional arrays and chained indexing, purely as syntactic sugar over regular arrays.
|
- Multidimensional arrays and chained indexing, purely as syntactic sugar over regular arrays.
|
||||||
|
@ -6,50 +6,42 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
|
str namestring = petscii:"The Quick Brown Fox Jumps Over The Lazy Dog\n0123456789!#$%^&*()-=_+[]{};:'<>,./?\n"
|
||||||
|
str namestring2 = petscii:"The Quick Brown Fox Jumps Over The Lazy Dog\n0123456789!#$%^&*()-=_+[]{};:'<>,./?\n"
|
||||||
|
txt.petscii2scr_str(namestring2)
|
||||||
|
for cx16.r0L in 0 to len(namestring) {
|
||||||
|
txt.print_ubhex(namestring[cx16.r0L], false)
|
||||||
|
txt.spc()
|
||||||
|
txt.print_ubhex(namestring2[cx16.r0L], false)
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
txt.nl()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
str name1 = ""
|
str name1 = ""
|
||||||
str name2 = "hello \r\n"
|
str name2 = "hello \r\n"
|
||||||
str name3 = " \n\rhello"
|
str name3 = " \n\rhello"
|
||||||
str name4 = " \n\r\xa0\xa0\xff\xffhello\x02\x02\x02 \n "
|
str name4 = " \n\r\xa0\xa0\xff\xffhello\x02\x02\x02 \n "
|
||||||
|
|
||||||
txt.print("strip:\n")
|
foo(name2)
|
||||||
string.strip(name1)
|
}
|
||||||
txt.chrout('[')
|
|
||||||
txt.print(name1)
|
|
||||||
txt.print("]\n")
|
|
||||||
string.strip(name2)
|
|
||||||
txt.chrout('[')
|
|
||||||
txt.print(name2)
|
|
||||||
txt.print("]\n")
|
|
||||||
string.strip(name3)
|
|
||||||
txt.chrout('[')
|
|
||||||
txt.print(name3)
|
|
||||||
txt.print("]\n")
|
|
||||||
string.strip(name4)
|
|
||||||
txt.chrout('[')
|
|
||||||
txt.print(name4)
|
|
||||||
txt.print("]\n")
|
|
||||||
|
|
||||||
str tname1 = ""
|
sub foo (str s2) {
|
||||||
str tname2 = "hello \r\n"
|
str s = "irmen"
|
||||||
str tname3 = " \n\r\x09hello"
|
txt.print_uwhex(s, true)
|
||||||
str tname4 = " \n\x09\x0b\r\xa0\xa0\xff\xffhello\x05\x05\x05 \n "
|
txt.nl()
|
||||||
|
txt.print_uwhex(&s, true)
|
||||||
txt.print("trim:\n")
|
txt.nl()
|
||||||
string.trim(tname1)
|
txt.print_uwhex(&s[2], true) ; TODO doesn't print correctly in the AST!
|
||||||
txt.chrout('[')
|
txt.nl()
|
||||||
txt.print(tname1)
|
txt.nl()
|
||||||
txt.print("]\n")
|
txt.print_uwhex(s2, true)
|
||||||
string.trim(tname2)
|
txt.nl()
|
||||||
txt.chrout('[')
|
txt.print_uwhex(&s2, true)
|
||||||
txt.print(tname2)
|
txt.nl()
|
||||||
txt.print("]\n")
|
txt.print_uwhex(s2+2, true)
|
||||||
string.trim(tname3)
|
txt.nl()
|
||||||
txt.chrout('[')
|
txt.print_uwhex(&s2[2], true) ; TODO should be the same as the previous one! TODO doesn't print correctly in the AST!
|
||||||
txt.print(tname3)
|
txt.nl()
|
||||||
txt.print("]\n")
|
|
||||||
string.trim(tname4)
|
|
||||||
txt.chrout('[')
|
|
||||||
txt.print(tname4)
|
|
||||||
txt.print("]\n")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user