fixed print_f on cx16. Some more examples are now multi-platform.

This commit is contained in:
Irmen de Jong 2020-09-22 01:34:05 +02:00
parent df995f7bc9
commit d1d224b7fc
9 changed files with 49 additions and 34 deletions

View File

@ -143,8 +143,8 @@ sub print_f (float value) {
jsr c64.CHROUT
iny
bne -
plx
+ rts
+ plx
rts
}}
}

View File

@ -2,8 +2,6 @@
%import textio
%zeropage basicsafe
; TODO fix crash on CX16
main {
sub start() {

View File

@ -2,8 +2,6 @@
%import textio
%zeropage basicsafe
; TODO fix crash on CX16
main {
sub start() {

View File

@ -2,8 +2,6 @@
%import textio
%zeropage basicsafe
; TODO fix crash on CX16
main {
sub start() {

View File

@ -2,8 +2,6 @@
%import textio
%zeropage basicsafe
; TODO fix crash on CX16
main {
sub start() {

View File

@ -2,8 +2,6 @@
%import textio
%zeropage basicsafe
; TODO fix crash on CX16
main {
sub start() {

View File

@ -3,7 +3,7 @@
%import floats
%zeropage basicsafe
; TODO use RDTIM() to get the time and make this system agnostic
; Note: this program is compatible with C64 and CX16.
main {
@ -18,27 +18,39 @@ main {
str question = "How are you?\n"
ubyte char
for char in question
c64.CHROUT(char)
txt.chrout(char)
; use indexed loop to write characters
str bye = "Goodbye!\n"
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)
clock_seconds -= hours*3600
float minutes = floor(clock_seconds / 60)
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)
c64.CHROUT(':')
txt.chrout(':')
floats.print_f(minutes)
c64.CHROUT(':')
txt.chrout(':')
floats.print_f(clock_seconds)
c64.CHROUT('\n')
txt.chrout('\n')
txt.print("bye!\n")
}

View File

@ -1,9 +1,8 @@
%import syslib
%import textio
%import floats
%zeropage basicsafe
; TODO use RDTIM() to get the time and make this system agnostic
; Note: this program is compatible with C64 and CX16.
main {
const uword width = 30
@ -13,9 +12,15 @@ main {
sub start() {
txt.print("calculating mandelbrot fractal...")
c64.TIME_HI=0
c64.TIME_MID=0
c64.TIME_LO=0
%asm {{
stx P8ZP_SCRATCH_REG
; reset the jiffy clock
ldx #0
ldy #0
lda #0
jsr c64.SETTIM
ldx P8ZP_SCRATCH_REG
}}
ubyte pixelx
ubyte pixely
@ -43,9 +48,20 @@ main {
}
}
float duration = ((c64.TIME_LO as float)
+ 256.0*(c64.TIME_MID as float)
+ 65536.0*(c64.TIME_HI as float))/60.0
ubyte time_lo
ubyte time_mid
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.print("finished in ")
floats.print_f(duration)

View File

@ -1,8 +1,7 @@
%target c64
%import textio
%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 {
@ -16,16 +15,14 @@ main {
txt.print("\n\n\n\nString output via print:\n")
txt.print("petscii-str: ")
txt.print(s1)
txt.print("\nscrcode-str: ")
txt.print(s2)
txt.print("\n\nThe top two screen lines are set via screencodes.\n")
ubyte i
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
@($0400+40+i) = s2[i]
txt.setchr(i, 1, s2[i])
ubyte c1 = 'z'
ubyte c2 = @'z'