mirror of
https://github.com/irmen/prog8.git
synced 2025-02-23 22:29:04 +00:00
moved wait() and reset_system() to sys block so they are now unified across c64 and cx16
This commit is contained in:
parent
3e7c7ab497
commit
cb65480c6c
@ -294,23 +294,6 @@ asmsub init_system() {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub reset_system() {
|
|
||||||
; Soft-reset the system back to Basic prompt.
|
|
||||||
%asm {{
|
|
||||||
sei
|
|
||||||
lda #14
|
|
||||||
sta $01 ; bank the kernal in
|
|
||||||
jmp (c64.RESET_VEC)
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub wait(uword jiffies) {
|
|
||||||
c64.SETTIM(0,0,0) ; TODO do the wait without resetting the jiffy clock
|
|
||||||
while c64.RDTIM16() < jiffies {
|
|
||||||
; wait till the time catches up
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
asmsub disable_runstop_and_charsetswitch() clobbers(A) {
|
asmsub disable_runstop_and_charsetswitch() clobbers(A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #$80
|
lda #$80
|
||||||
@ -486,9 +469,28 @@ _raster_irq_handler
|
|||||||
|
|
||||||
; ---- end of C64 specific system utility routines ----
|
; ---- end of C64 specific system utility routines ----
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys {
|
||||||
|
; ------- lowlevel system routines --------
|
||||||
|
|
||||||
|
asmsub reset_system() {
|
||||||
|
; Soft-reset the system back to Basic prompt.
|
||||||
|
%asm {{
|
||||||
|
sei
|
||||||
|
lda #14
|
||||||
|
sta $01 ; bank the kernal in
|
||||||
|
jmp (c64.RESET_VEC)
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub wait(uword jiffies) {
|
||||||
|
c64.SETTIM(0,0,0) ; TODO do the wait without resetting the jiffy clock
|
||||||
|
while c64.RDTIM16() < jiffies {
|
||||||
|
; wait till the time catches up
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cx16 {
|
cx16 {
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ asmsub STOP2() -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub RDTIM16() -> uword @AY {
|
asmsub RDTIM16() -> uword @AY {
|
||||||
; -- like RDTIM() but only returning the lower 16 bits for convenience
|
; -- like RDTIM() but only returning the lower 16 bits for convenience
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -88,7 +87,6 @@ asmsub RDTIM16() -> uword @AY {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cx16 {
|
cx16 {
|
||||||
@ -276,9 +274,9 @@ romsub $fed2 = kbdbuf_put(ubyte key @A) clobbers(A,X,Y)
|
|||||||
romsub $fecf = entropy_get() -> ubyte @A, ubyte @X, ubyte @Y
|
romsub $fecf = entropy_get() -> ubyte @A, ubyte @X, ubyte @Y
|
||||||
romsub $fecc = monitor() clobbers(A,X,Y)
|
romsub $fecc = monitor() clobbers(A,X,Y)
|
||||||
|
|
||||||
|
|
||||||
; ---- end of kernal routines ----
|
; ---- end of kernal routines ----
|
||||||
|
|
||||||
|
|
||||||
; ---- utilities -----
|
; ---- utilities -----
|
||||||
asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A {
|
asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A {
|
||||||
; -- get a byte from VERA's video memory
|
; -- get a byte from VERA's video memory
|
||||||
@ -297,7 +295,6 @@ asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub vaddr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, byte autoIncrOrDecrByOne @Y) clobbers(A) {
|
asmsub vaddr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, byte autoIncrOrDecrByOne @Y) clobbers(A) {
|
||||||
; -- setup the VERA's data address register 0 or 1
|
; -- setup the VERA's data address register 0 or 1
|
||||||
%asm {{
|
%asm {{
|
||||||
@ -323,7 +320,6 @@ asmsub vaddr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, byte autoIncrO
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
asmsub vpoke(ubyte bank @A, uword address @R0, ubyte value @Y) clobbers(A) {
|
asmsub vpoke(ubyte bank @A, uword address @R0, ubyte value @Y) clobbers(A) {
|
||||||
; -- write a single byte to VERA's video memory
|
; -- write a single byte to VERA's video memory
|
||||||
; note: inefficient when writing multiple sequential bytes!
|
; note: inefficient when writing multiple sequential bytes!
|
||||||
@ -428,18 +424,7 @@ _loop ldy #0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub wait(uword jiffies) {
|
|
||||||
c64.SETTIM(0,0,0) ; TODO do the wait without resetting the jiffy clock
|
|
||||||
while c64.RDTIM16() < jiffies {
|
|
||||||
; wait till the time catches up
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
; ---- system stuff -----
|
; ---- system stuff -----
|
||||||
|
|
||||||
asmsub init_system() {
|
asmsub init_system() {
|
||||||
; Initializes the machine to a sane starting state.
|
; Initializes the machine to a sane starting state.
|
||||||
; Called automatically by the loader program logic.
|
; Called automatically by the loader program logic.
|
||||||
@ -472,15 +457,27 @@ asmsub init_system() {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub reset_system() {
|
|
||||||
; Soft-reset the system back to Basic prompt.
|
|
||||||
%asm {{
|
|
||||||
sei
|
|
||||||
lda #14
|
|
||||||
sta $01
|
|
||||||
stz cx16.d1prb ; bank the kernal in
|
|
||||||
jmp (cx16.RESET_VEC)
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys {
|
||||||
|
; ------- lowlevel system routines --------
|
||||||
|
|
||||||
|
asmsub reset_system() {
|
||||||
|
; Soft-reset the system back to Basic prompt.
|
||||||
|
%asm {{
|
||||||
|
sei
|
||||||
|
lda #14
|
||||||
|
sta $01
|
||||||
|
stz cx16.d1prb ; bank the kernal in
|
||||||
|
jmp (cx16.RESET_VEC)
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub wait(uword jiffies) {
|
||||||
|
c64.SETTIM(0,0,0) ; TODO do the wait without resetting the jiffy clock
|
||||||
|
while c64.RDTIM16() < jiffies {
|
||||||
|
; wait till the time catches up
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,9 +152,9 @@ internal class AsmGen(private val program: Program,
|
|||||||
if(options.zeropage !in setOf(ZeropageType.BASICSAFE, ZeropageType.DONTUSE)) {
|
if(options.zeropage !in setOf(ZeropageType.BASICSAFE, ZeropageType.DONTUSE)) {
|
||||||
out("""
|
out("""
|
||||||
; zeropage is clobbered so we need to reset the machine at exit
|
; zeropage is clobbered so we need to reset the machine at exit
|
||||||
lda #>${CompilationTarget.instance.name}.reset_system
|
lda #>sys.reset_system
|
||||||
pha
|
pha
|
||||||
lda #<${CompilationTarget.instance.name}.reset_system
|
lda #<sys.reset_system
|
||||||
pha""")
|
pha""")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ TODO
|
|||||||
|
|
||||||
- move all str* builtin functions to a str library module
|
- move all str* builtin functions to a str library module
|
||||||
- make the syslib.wait() functions not reset the jiffy clock to 0
|
- make the syslib.wait() functions not reset the jiffy clock to 0
|
||||||
- move wait() and others? to sys.* block to unify them from c64.* and cx16.* separation
|
|
||||||
- detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation
|
- detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation
|
||||||
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
|
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)
|
||||||
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'
|
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'
|
||||||
|
@ -37,7 +37,7 @@ main {
|
|||||||
angley+=217
|
angley+=217
|
||||||
anglez+=452
|
anglez+=452
|
||||||
|
|
||||||
c64.wait(2)
|
sys.wait(2)
|
||||||
|
|
||||||
; test_stack.test()
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ main {
|
|||||||
}
|
}
|
||||||
gfx2.text(80, 420, 1, @"cos(x)+x")
|
gfx2.text(80, 420, 1, @"cos(x)+x")
|
||||||
|
|
||||||
cx16.wait(3*60)
|
sys.wait(3*60)
|
||||||
|
|
||||||
gfx2.circle(320, 240, 220, 1)
|
gfx2.circle(320, 240, 220, 1)
|
||||||
gfx2.circle(320, 240, 210, 1)
|
gfx2.circle(320, 240, 210, 1)
|
||||||
@ -74,11 +74,11 @@ main {
|
|||||||
gfx2.disc(320, 240, 90, 1)
|
gfx2.disc(320, 240, 90, 1)
|
||||||
gfx2.disc(320, 240, 40, 0)
|
gfx2.disc(320, 240, 40, 0)
|
||||||
|
|
||||||
cx16.wait(2*60)
|
sys.wait(2*60)
|
||||||
|
|
||||||
repeat 255
|
repeat 255
|
||||||
gfx2.line(rndw() % 640, rndw() % 480, rndw() % 640, rndw() % 480, 1)
|
gfx2.line(rndw() % 640, rndw() % 480, rndw() % 640, rndw() % 480, 1)
|
||||||
|
|
||||||
cx16.wait(1*60)
|
sys.wait(1*60)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,12 @@ main {
|
|||||||
if iff_module.show_image(filenameptr) {
|
if iff_module.show_image(filenameptr) {
|
||||||
if iff_module.num_cycles {
|
if iff_module.num_cycles {
|
||||||
repeat 500 {
|
repeat 500 {
|
||||||
cx16.wait(1)
|
sys.wait(1)
|
||||||
iff_module.cycle_colors_each_jiffy()
|
iff_module.cycle_colors_each_jiffy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cx16.wait(180)
|
sys.wait(180)
|
||||||
} else {
|
} else {
|
||||||
load_error(filenameptr)
|
load_error(filenameptr)
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ main {
|
|||||||
;txt.print("loading ")
|
;txt.print("loading ")
|
||||||
;txt.print("pcx\n")
|
;txt.print("pcx\n")
|
||||||
if pcx_module.show_image(filenameptr) {
|
if pcx_module.show_image(filenameptr) {
|
||||||
cx16.wait(180)
|
sys.wait(180)
|
||||||
} else {
|
} else {
|
||||||
load_error(filenameptr)
|
load_error(filenameptr)
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ main {
|
|||||||
;txt.print("loading ")
|
;txt.print("loading ")
|
||||||
;txt.print("koala\n")
|
;txt.print("koala\n")
|
||||||
if koala_module.show_image(filenameptr) {
|
if koala_module.show_image(filenameptr) {
|
||||||
cx16.wait(180)
|
sys.wait(180)
|
||||||
} else {
|
} else {
|
||||||
load_error(filenameptr)
|
load_error(filenameptr)
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ main {
|
|||||||
;txt.print("loading ")
|
;txt.print("loading ")
|
||||||
;txt.print("bmp\n")
|
;txt.print("bmp\n")
|
||||||
if bmp_module.show_image(filenameptr) {
|
if bmp_module.show_image(filenameptr) {
|
||||||
cx16.wait(180)
|
sys.wait(180)
|
||||||
} else {
|
} else {
|
||||||
load_error(filenameptr)
|
load_error(filenameptr)
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ main {
|
|||||||
;; txt.print("loading ")
|
;; txt.print("loading ")
|
||||||
;; txt.print("ci\n")
|
;; txt.print("ci\n")
|
||||||
; if ci_module.show_image(filenameptr) {
|
; if ci_module.show_image(filenameptr) {
|
||||||
; cx16.wait(180)
|
; sys.wait(180)
|
||||||
; } else {
|
; } else {
|
||||||
; load_error(filenameptr)
|
; load_error(filenameptr)
|
||||||
; }
|
; }
|
||||||
|
@ -125,7 +125,7 @@ main {
|
|||||||
xx+=4
|
xx+=4
|
||||||
}
|
}
|
||||||
|
|
||||||
cx16.wait(3*60)
|
sys.wait(3*60)
|
||||||
|
|
||||||
demo2()
|
demo2()
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ main {
|
|||||||
for mode in modes {
|
for mode in modes {
|
||||||
gfx2.screen_mode(mode)
|
gfx2.screen_mode(mode)
|
||||||
draw()
|
draw()
|
||||||
cx16.wait(200)
|
sys.wait(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ main {
|
|||||||
gfx2.line(x1, y1, x2, y2, i+1)
|
gfx2.line(x1, y1, x2, y2, i+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
cx16.wait(60)
|
sys.wait(60)
|
||||||
gfx2.clear_screen()
|
gfx2.clear_screen()
|
||||||
|
|
||||||
ubyte radius
|
ubyte radius
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%zeropage full
|
||||||
%zeropage basicsafe
|
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -9,11 +8,11 @@ main {
|
|||||||
sub start () {
|
sub start () {
|
||||||
uword current_time
|
uword current_time
|
||||||
|
|
||||||
repeat {
|
repeat 5 {
|
||||||
current_time = c64.RDTIM16()
|
current_time = c64.RDTIM16()
|
||||||
txt.print_uw(current_time)
|
txt.print_uw(current_time)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
repeat 20000 {
|
repeat 60000 {
|
||||||
current_time++
|
current_time++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user