mirror of
https://github.com/irmen/prog8.git
synced 2024-07-13 12:29:05 +00:00
fixed print_f on cx16. Some more examples are now multi-platform.
This commit is contained in:
parent
df995f7bc9
commit
d1d224b7fc
@ -143,8 +143,8 @@ sub print_f (float value) {
|
|||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
iny
|
iny
|
||||||
bne -
|
bne -
|
||||||
plx
|
+ plx
|
||||||
+ rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO fix crash on CX16
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO fix crash on CX16
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO fix crash on CX16
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO fix crash on CX16
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO fix crash on CX16
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
%import floats
|
%import floats
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO use RDTIM() to get the time and make this system agnostic
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
@ -18,27 +18,39 @@ main {
|
|||||||
str question = "How are you?\n"
|
str question = "How are you?\n"
|
||||||
ubyte char
|
ubyte char
|
||||||
for char in question
|
for char in question
|
||||||
c64.CHROUT(char)
|
txt.chrout(char)
|
||||||
|
|
||||||
; use indexed loop to write characters
|
; use indexed loop to write characters
|
||||||
str bye = "Goodbye!\n"
|
str bye = "Goodbye!\n"
|
||||||
for char in 0 to len(bye)-1
|
for char in 0 to len(bye)-1
|
||||||
c64.CHROUT(bye[char])
|
txt.chrout(bye[char])
|
||||||
|
|
||||||
|
ubyte time_lo
|
||||||
|
ubyte time_mid
|
||||||
|
ubyte time_hi
|
||||||
|
|
||||||
float clock_seconds = ((mkword(c64.TIME_MID, c64.TIME_LO) as float) + (c64.TIME_HI as float)*65536.0) / 60
|
%asm {{
|
||||||
|
stx P8ZP_SCRATCH_REG
|
||||||
|
jsr c64.RDTIM ; A/X/Y
|
||||||
|
sta time_lo
|
||||||
|
stx time_mid
|
||||||
|
sty time_hi
|
||||||
|
ldx P8ZP_SCRATCH_REG
|
||||||
|
}}
|
||||||
|
|
||||||
|
float clock_seconds = ((mkword(time_mid, time_lo) as float) + (time_hi as float)*65536.0) / 60
|
||||||
float hours = floor(clock_seconds / 3600)
|
float hours = floor(clock_seconds / 3600)
|
||||||
clock_seconds -= hours*3600
|
clock_seconds -= hours*3600
|
||||||
float minutes = floor(clock_seconds / 60)
|
float minutes = floor(clock_seconds / 60)
|
||||||
clock_seconds = floor(clock_seconds - minutes * 60.0)
|
clock_seconds = floor(clock_seconds - minutes * 60.0)
|
||||||
|
|
||||||
txt.print("system time in ti$ is ")
|
txt.print("system time (jiffy clock) is ")
|
||||||
floats.print_f(hours)
|
floats.print_f(hours)
|
||||||
c64.CHROUT(':')
|
txt.chrout(':')
|
||||||
floats.print_f(minutes)
|
floats.print_f(minutes)
|
||||||
c64.CHROUT(':')
|
txt.chrout(':')
|
||||||
floats.print_f(clock_seconds)
|
floats.print_f(clock_seconds)
|
||||||
c64.CHROUT('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
txt.print("bye!\n")
|
txt.print("bye!\n")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
%import syslib
|
|
||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%import floats
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO use RDTIM() to get the time and make this system agnostic
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
main {
|
main {
|
||||||
const uword width = 30
|
const uword width = 30
|
||||||
@ -13,9 +12,15 @@ main {
|
|||||||
sub start() {
|
sub start() {
|
||||||
txt.print("calculating mandelbrot fractal...")
|
txt.print("calculating mandelbrot fractal...")
|
||||||
|
|
||||||
c64.TIME_HI=0
|
%asm {{
|
||||||
c64.TIME_MID=0
|
stx P8ZP_SCRATCH_REG
|
||||||
c64.TIME_LO=0
|
; reset the jiffy clock
|
||||||
|
ldx #0
|
||||||
|
ldy #0
|
||||||
|
lda #0
|
||||||
|
jsr c64.SETTIM
|
||||||
|
ldx P8ZP_SCRATCH_REG
|
||||||
|
}}
|
||||||
|
|
||||||
ubyte pixelx
|
ubyte pixelx
|
||||||
ubyte pixely
|
ubyte pixely
|
||||||
@ -43,9 +48,20 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float duration = ((c64.TIME_LO as float)
|
ubyte time_lo
|
||||||
+ 256.0*(c64.TIME_MID as float)
|
ubyte time_mid
|
||||||
+ 65536.0*(c64.TIME_HI as float))/60.0
|
ubyte time_hi
|
||||||
|
|
||||||
|
%asm {{
|
||||||
|
stx P8ZP_SCRATCH_REG
|
||||||
|
jsr c64.RDTIM ; A/X/Y
|
||||||
|
sta time_lo
|
||||||
|
stx time_mid
|
||||||
|
sty time_hi
|
||||||
|
ldx P8ZP_SCRATCH_REG
|
||||||
|
}}
|
||||||
|
|
||||||
|
float duration = ((mkword(time_mid, time_lo) as float) + (time_hi as float)*65536.0) / 60
|
||||||
txt.plot(0, 21)
|
txt.plot(0, 21)
|
||||||
txt.print("finished in ")
|
txt.print("finished in ")
|
||||||
floats.print_f(duration)
|
floats.print_f(duration)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
%target c64
|
|
||||||
%import textio
|
%import textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; TODO use setcc instead of poking screen ram directly to make this cross-system
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
@ -16,16 +15,14 @@ main {
|
|||||||
txt.print("\n\n\n\nString output via print:\n")
|
txt.print("\n\n\n\nString output via print:\n")
|
||||||
txt.print("petscii-str: ")
|
txt.print("petscii-str: ")
|
||||||
txt.print(s1)
|
txt.print(s1)
|
||||||
txt.print("\nscrcode-str: ")
|
|
||||||
txt.print(s2)
|
|
||||||
|
|
||||||
txt.print("\n\nThe top two screen lines are set via screencodes.\n")
|
txt.print("\n\nThe top two screen lines are set via screencodes.\n")
|
||||||
ubyte i
|
ubyte i
|
||||||
for i in 0 to len(s1)-1
|
for i in 0 to len(s1)-1
|
||||||
@($0400+i) = s1[i]
|
txt.setchr(i, 0, s1[i])
|
||||||
|
|
||||||
for i in 0 to len(s2)-1
|
for i in 0 to len(s2)-1
|
||||||
@($0400+40+i) = s2[i]
|
txt.setchr(i, 1, s2[i])
|
||||||
|
|
||||||
ubyte c1 = 'z'
|
ubyte c1 = 'z'
|
||||||
ubyte c2 = @'z'
|
ubyte c2 = @'z'
|
||||||
|
Loading…
Reference in New Issue
Block a user