mirror of
https://github.com/irmen/prog8.git
synced 2025-08-11 17:26:01 +00:00
readme
This commit is contained in:
@@ -24,8 +24,8 @@ Prog8 is copyright © Irmen de Jong (irmen@razorvine.net | http://www.razorvine.
|
|||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
|
|
||||||
Appetizer
|
Code example
|
||||||
---------
|
------------
|
||||||
|
|
||||||
When this code is compiled::
|
When this code is compiled::
|
||||||
|
|
||||||
@@ -53,7 +53,9 @@ When this code is compiled::
|
|||||||
c64.CHROUT(bye[c])
|
c64.CHROUT(bye[c])
|
||||||
|
|
||||||
|
|
||||||
float clock_seconds = ((mkword(c64.TIME_LO, c64.TIME_MID) as float) + (c64.TIME_HI as float)*65536.0) / 60
|
float clock_seconds = ((mkword(c64.TIME_LO, c64.TIME_MID) as float)
|
||||||
|
+ (c64.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)
|
||||||
@@ -70,6 +72,7 @@ When this code is compiled::
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
you get a program that outputs this when loaded on a C-64:
|
you get a program that outputs this when loaded on a C-64:
|
||||||
|
|
||||||
.. image:: _static/hello_screen.png
|
.. image:: _static/hello_screen.png
|
||||||
|
@@ -1,26 +1,41 @@
|
|||||||
%import c64lib
|
%import c64lib
|
||||||
%import c64utils
|
%import c64utils
|
||||||
|
%import c64flt
|
||||||
|
|
||||||
~ main {
|
|
||||||
|
|
||||||
|
~ main {
|
||||||
sub start() {
|
sub start() {
|
||||||
|
; set text color and activate lowercase charset
|
||||||
|
c64.COLOR = 13
|
||||||
|
c64.VMCSB |= 2
|
||||||
|
|
||||||
uword num_hours=2
|
; use optimized routine to write text
|
||||||
uword num_minutes=10
|
c64scr.print("Hello!\n")
|
||||||
uword num_seconds=14
|
|
||||||
|
|
||||||
uword total = num_hours * 3600 + num_minutes * 60 + num_seconds
|
; use iteration to write text
|
||||||
|
str question = "How are you?\n"
|
||||||
|
for ubyte char in question
|
||||||
|
c64.CHROUT(char)
|
||||||
|
|
||||||
uword total2 = num_hours * 3600
|
; use indexed loop to write characters
|
||||||
+ num_minutes * 60
|
str bye = "Goodbye!\n"
|
||||||
+ num_seconds
|
for ubyte c in 0 to len(bye)
|
||||||
|
c64.CHROUT(bye[c])
|
||||||
|
|
||||||
c64scr.print_uw(total)
|
|
||||||
|
float clock_seconds = ((mkword(c64.TIME_LO, c64.TIME_MID) as float)
|
||||||
|
+ (c64.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)
|
||||||
|
|
||||||
|
c64scr.print("system time in ti$ is ")
|
||||||
|
c64flt.print_f(hours)
|
||||||
|
c64.CHROUT(':')
|
||||||
|
c64flt.print_f(minutes)
|
||||||
|
c64.CHROUT(':')
|
||||||
|
c64flt.print_f(clock_seconds)
|
||||||
c64.CHROUT('\n')
|
c64.CHROUT('\n')
|
||||||
c64scr.print_uw(total2)
|
|
||||||
c64.CHROUT('\n')
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user