mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +00:00
stack tested for most example programs
This commit is contained in:
parent
125f6205f2
commit
510ca042c9
@ -12,11 +12,20 @@ graphics {
|
|||||||
|
|
||||||
sub enable_bitmap_mode() {
|
sub enable_bitmap_mode() {
|
||||||
; enable bitmap screen, erase it and set colors to black/white.
|
; enable bitmap screen, erase it and set colors to black/white.
|
||||||
c64.SCROLY |= %00100000
|
c64.SCROLY = %00111000
|
||||||
|
c64.SCROLX = %00001000
|
||||||
c64.VMCSB = (c64.VMCSB & %11110000) | %00001000 ; $2000-$3fff
|
c64.VMCSB = (c64.VMCSB & %11110000) | %00001000 ; $2000-$3fff
|
||||||
clear_screen(1, 0)
|
clear_screen(1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub disable_bitmap_mode() {
|
||||||
|
; enables text mode, erase the text screen, color white
|
||||||
|
c64.SCROLY = %00011000
|
||||||
|
c64.SCROLX = %00001000
|
||||||
|
c64.VMCSB = (c64.VMCSB & %11110000) | %00000100 ; $1000-$2fff
|
||||||
|
txt.fill_screen(' ', 1)
|
||||||
|
}
|
||||||
|
|
||||||
sub clear_screen(ubyte pixelcolor, ubyte bgcolor) {
|
sub clear_screen(ubyte pixelcolor, ubyte bgcolor) {
|
||||||
memset(BITMAP_ADDRESS, 320*200/8, 0)
|
memset(BITMAP_ADDRESS, 320*200/8, 0)
|
||||||
txt.fill_screen(pixelcolor << 4 | bgcolor, 0)
|
txt.fill_screen(pixelcolor << 4 | bgcolor, 0)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%target cx16
|
%target cx16
|
||||||
%import syslib
|
%import syslib
|
||||||
|
%import textio
|
||||||
|
|
||||||
; bitmap pixel graphics module for the CommanderX16
|
; bitmap pixel graphics module for the CommanderX16
|
||||||
; wraps the graphics functions that are in ROM.
|
; wraps the graphics functions that are in ROM.
|
||||||
@ -17,6 +18,13 @@ graphics {
|
|||||||
clear_screen(1, 0)
|
clear_screen(1, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub disable_bitmap_mode() {
|
||||||
|
; enables text mode, erase the text screen, color white
|
||||||
|
void cx16.screen_set_mode(2)
|
||||||
|
txt.fill_screen(' ', 1) ; TODO doesn't seem to fully clear the text screen after returning from gfx mode
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub clear_screen(ubyte pixelcolor, ubyte bgcolor) {
|
sub clear_screen(ubyte pixelcolor, ubyte bgcolor) {
|
||||||
cx16.GRAPH_set_colors(pixelcolor, pixelcolor, bgcolor)
|
cx16.GRAPH_set_colors(pixelcolor, pixelcolor, bgcolor)
|
||||||
cx16.GRAPH_clear()
|
cx16.GRAPH_clear()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
%import textio
|
||||||
|
|
||||||
test_stack {
|
test_stack {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- check cpu stack consistency in all examples
|
|
||||||
- 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 '_'
|
||||||
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
|
- option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging)
|
||||||
- see if we can group some errors together for instance the (now single) errors about unidentified symbols
|
- see if we can group some errors together for instance the (now single) errors about unidentified symbols
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import syslib
|
%import syslib
|
||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -23,6 +24,9 @@ main {
|
|||||||
ubyte upwards = true
|
ubyte upwards = true
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
|
;txt.plot(0,0)
|
||||||
|
;test_stack.test()
|
||||||
|
|
||||||
ubyte mountain = 223 ; slope upwards
|
ubyte mountain = 223 ; slope upwards
|
||||||
if active_height < target_height {
|
if active_height < target_height {
|
||||||
active_height++
|
active_height++
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
|
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -86,12 +88,16 @@ main {
|
|||||||
; read clock
|
; read clock
|
||||||
uword jiffies
|
uword jiffies
|
||||||
%asm {{
|
%asm {{
|
||||||
|
stx P8ZP_SCRATCH_REG
|
||||||
jsr c64.RDTIM
|
jsr c64.RDTIM
|
||||||
sta jiffies
|
sta jiffies
|
||||||
stx jiffies+1
|
stx jiffies+1
|
||||||
|
ldx P8ZP_SCRATCH_REG
|
||||||
}}
|
}}
|
||||||
txt.print("\nbenchmark: ")
|
txt.print("\nbenchmark: ")
|
||||||
txt.print_uw(jiffies)
|
txt.print_uw(jiffies)
|
||||||
txt.print(" jiffies for 1000 frames.\n")
|
txt.print(" jiffies for 1000 frames.\n")
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import floats
|
%import floats
|
||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -41,6 +42,8 @@ main {
|
|||||||
txt.print(" jiffies/fr = ")
|
txt.print(" jiffies/fr = ")
|
||||||
txt.print_ub(60/timer_jiffies)
|
txt.print_ub(60/timer_jiffies)
|
||||||
txt.print(" fps")
|
txt.print(" fps")
|
||||||
|
|
||||||
|
;test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import syslib
|
%import syslib
|
||||||
%import graphics
|
%import graphics
|
||||||
|
%import test_stack
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
@ -37,6 +38,8 @@ main {
|
|||||||
anglez+=452
|
anglez+=452
|
||||||
|
|
||||||
wait_a_little_bit()
|
wait_a_little_bit()
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import syslib
|
%import syslib
|
||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
|
|
||||||
spritedata $2000 {
|
spritedata $2000 {
|
||||||
; this memory block contains the sprite data
|
; this memory block contains the sprite data
|
||||||
@ -95,6 +96,8 @@ main {
|
|||||||
txt.print(" jiffies/fr = ")
|
txt.print(" jiffies/fr = ")
|
||||||
txt.print_ub(60/c64.TIME_LO)
|
txt.print_ub(60/c64.TIME_LO)
|
||||||
txt.print(" fps")
|
txt.print(" fps")
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import syslib
|
%import syslib
|
||||||
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -33,6 +34,8 @@ main {
|
|||||||
txt.print_ub(60/c64.TIME_LO)
|
txt.print_ub(60/c64.TIME_LO)
|
||||||
txt.print(" fps")
|
txt.print(" fps")
|
||||||
c64.TIME_LO=0
|
c64.TIME_LO=0
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%target cx16
|
%target cx16
|
||||||
%import syslib
|
%import syslib
|
||||||
|
%import test_stack
|
||||||
%import conv
|
%import conv
|
||||||
|
|
||||||
; TODO add all other Elite's ships, show their name, advance to next ship on keypress
|
; TODO add all other Elite's ships, show their name, advance to next ship on keypress
|
||||||
@ -41,6 +42,8 @@ main {
|
|||||||
anglex += 217
|
anglex += 217
|
||||||
angley -= 505
|
angley -= 505
|
||||||
anglez += 452
|
anglez += 452
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
%import graphics
|
%import graphics
|
||||||
|
%import test_stack
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
|
|
||||||
@ -6,8 +7,13 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
graphics.enable_bitmap_mode()
|
graphics.enable_bitmap_mode()
|
||||||
|
|
||||||
draw_lines()
|
draw_lines()
|
||||||
draw_circles()
|
draw_circles()
|
||||||
|
|
||||||
|
; graphics.disable_bitmap_mode()
|
||||||
|
; test_stack.test()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import syslib
|
%import syslib
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -40,6 +41,8 @@ main {
|
|||||||
rect(10, 10, 10, 10, false)
|
rect(10, 10, 10, 10, false)
|
||||||
rect(6, 0, 16, 20, true)
|
rect(6, 0, 16, 20, true)
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
|
|
||||||
|
|
||||||
sub rect(ubyte x1, ubyte y1, ubyte x2, ubyte y2, ubyte fill) {
|
sub rect(ubyte x1, ubyte y1, ubyte x2, ubyte y2, ubyte fill) {
|
||||||
ubyte x
|
ubyte x
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import graphics
|
%import graphics
|
||||||
%import floats
|
%import floats
|
||||||
|
%import test_stack
|
||||||
%zeropage floatsafe
|
%zeropage floatsafe
|
||||||
|
|
||||||
; Draw a mandelbrot in graphics mode (the image will be 256 x 200 pixels).
|
; Draw a mandelbrot in graphics mode (the image will be 256 x 200 pixels).
|
||||||
@ -44,6 +45,8 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%import floats
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -57,5 +58,7 @@ main {
|
|||||||
txt.print("finished in ")
|
txt.print("finished in ")
|
||||||
floats.print_f(duration)
|
floats.print_f(duration)
|
||||||
txt.print(" seconds!\n")
|
txt.print(" seconds!\n")
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; The classic number guessing game.
|
; The classic number guessing game.
|
||||||
@ -59,6 +60,8 @@ main {
|
|||||||
txt.print("Thanks for playing, ")
|
txt.print("Thanks for playing, ")
|
||||||
txt.print(name)
|
txt.print(name)
|
||||||
txt.print(".\n")
|
txt.print(".\n")
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import syslib
|
%import syslib
|
||||||
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
|
||||||
; converted from plasma test program for cc65.
|
; converted from plasma test program for cc65.
|
||||||
@ -26,7 +27,7 @@ main {
|
|||||||
; ubyte v = c64.VMCSB
|
; ubyte v = c64.VMCSB
|
||||||
c64.CIA2PRA = (block & $FC) | (lsb(SCREEN1 >> 14) ^ $03)
|
c64.CIA2PRA = (block & $FC) | (lsb(SCREEN1 >> 14) ^ $03)
|
||||||
|
|
||||||
repeat {
|
repeat 100 {
|
||||||
doplasma(SCREEN1)
|
doplasma(SCREEN1)
|
||||||
c64.VMCSB = PAGE1
|
c64.VMCSB = PAGE1
|
||||||
doplasma(SCREEN2)
|
doplasma(SCREEN2)
|
||||||
@ -37,6 +38,9 @@ main {
|
|||||||
;c64.VMCSB = v
|
;c64.VMCSB = v
|
||||||
;c64.CIA2PRA = block
|
;c64.CIA2PRA = block
|
||||||
;txt.print("done!\n")
|
;txt.print("done!\n")
|
||||||
|
;test_stack.test()
|
||||||
|
;repeat {
|
||||||
|
;}
|
||||||
}
|
}
|
||||||
|
|
||||||
; several variables outside of doplasma to make them retain their value
|
; several variables outside of doplasma to make them retain their value
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -26,6 +27,8 @@ main {
|
|||||||
txt.print("number of primes (expected 54): ")
|
txt.print("number of primes (expected 54): ")
|
||||||
txt.print_ub(amount)
|
txt.print_ub(amount)
|
||||||
txt.chrout('\n')
|
txt.chrout('\n')
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -31,6 +32,7 @@ main {
|
|||||||
txt.print("reversed\n")
|
txt.print("reversed\n")
|
||||||
print_arrays()
|
print_arrays()
|
||||||
|
|
||||||
|
;test_stack.test()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import syslib
|
%import syslib
|
||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -67,6 +68,9 @@ waitkey:
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawScore()
|
drawScore()
|
||||||
|
|
||||||
|
; txt.plot(0,0)
|
||||||
|
; test_stack.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
ubyte key=c64.GETIN()
|
ubyte key=c64.GETIN()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
%import textio
|
%import textio
|
||||||
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Note: this program is compatible with C64 and CX16.
|
; Note: this program is compatible with C64 and CX16.
|
||||||
@ -963,6 +964,9 @@ main {
|
|||||||
txt.print("ok\n")
|
txt.print("ok\n")
|
||||||
else
|
else
|
||||||
txt.print("fail!!!\n")
|
txt.print("fail!!!\n")
|
||||||
|
|
||||||
|
|
||||||
|
test_stack.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
sub wait_input() {
|
sub wait_input() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
%import diskio
|
%import diskio
|
||||||
|
%import test_stack
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
@ -26,6 +27,8 @@ main {
|
|||||||
planet.display(false)
|
planet.display(false)
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
|
; test_stack.test()
|
||||||
|
|
||||||
str input = "????????"
|
str input = "????????"
|
||||||
txt.print("\nCash: ")
|
txt.print("\nCash: ")
|
||||||
util.print_10s(ship.cash)
|
util.print_10s(ship.cash)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
%target c64
|
%target c64
|
||||||
%import floats
|
%import floats
|
||||||
%import graphics
|
%import graphics
|
||||||
|
%import test_stack
|
||||||
%zeropage floatsafe
|
%zeropage floatsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -18,6 +19,8 @@ main {
|
|||||||
turtle.rt(94)
|
turtle.rt(94)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; test_stack.test()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user